Search code examples
special-characterscatkeycodenotationnon-printing-characters

What is the "M- notation" and where is it documented?


The man page of cat says:

-v, --show-nonprinting
    use ^ and M- notation, except for LFD and TAB 

What is the M- notation and where is it documented?

Example:

$cat log -A
wrote 262144 bytes from file test.x in 9.853947s (25.979 KiB/s)^M$
^M> ^H^H  ^H^H>

What do ^M and ^H mean?


Solution

  • I was wondering this too. I checked the source but it seemed easier to create a input file to get the mapping.

    I created a test input file with a Perl scrip for( my $i=0 ; $i < 256; $i++ ) { print ( sprintf( "%c is %d %x\n", $i, $i ,$i ) ); } and then ran it through cat -v

    Also if you see M-oM-;M-? at the start of a file it is the UTF-8 byte order mark.

    Scroll down through these to get to the M- values:

    ^@ is 0 0
    ^A is 1 1
    ^B is 2 2
    ^C is 3 3
    ^D is 4 4
    ^E is 5 5
    ^F is 6 6
    ^G is 7 7
    ^H is 8 8
    (9 is tab)
    (10 is NL)
    ^K is 11 b
    ^L is 12 c
    ^M is 13 d
    ^N is 14 e
    ^O is 15 f
    ^P is 16 10
    ^Q is 17 11
    ^R is 18 12
    ^S is 19 13
    ^T is 20 14
    ^U is 21 15
    ^V is 22 16
    ^W is 23 17
    ^X is 24 18
    ^Y is 25 19
    ^Z is 26 1a
    ^[ is 27 1b
    ^\ is 28 1c
    ^] is 29 1d
    ^^ is 30 1e
    ^_ is 31 1f
    ...printing chars removed...
    ^? is 127 7f
    M-^@ is 128 80
    M-^A is 129 81
    M-^B is 130 82
    M-^C is 131 83
    M-^D is 132 84
    M-^E is 133 85
    M-^F is 134 86
    M-^G is 135 87
    M-^H is 136 88
    M-^I is 137 89
    M-^J is 138 8a
    M-^K is 139 8b
    M-^L is 140 8c
    M-^M is 141 8d
    M-^N is 142 8e
    M-^O is 143 8f
    M-^P is 144 90
    M-^Q is 145 91
    M-^R is 146 92
    M-^S is 147 93
    M-^T is 148 94
    M-^U is 149 95
    M-^V is 150 96
    M-^W is 151 97
    M-^X is 152 98
    M-^Y is 153 99
    M-^Z is 154 9a
    M-^[ is 155 9b
    M-^\ is 156 9c
    M-^] is 157 9d
    M-^^ is 158 9e
    M-^_ is 159 9f
    M-  is 160 a0
    M-! is 161 a1
    M-" is 162 a2
    M-# is 163 a3
    M-$ is 164 a4
    M-% is 165 a5
    M-& is 166 a6
    M-' is 167 a7
    M-( is 168 a8
    M-) is 169 a9
    M-* is 170 aa
    M-+ is 171 ab
    M-, is 172 ac
    M-- is 173 ad
    M-. is 174 ae
    M-/ is 175 af
    M-0 is 176 b0
    M-1 is 177 b1
    M-2 is 178 b2
    M-3 is 179 b3
    M-4 is 180 b4
    M-5 is 181 b5
    M-6 is 182 b6
    M-7 is 183 b7
    M-8 is 184 b8
    M-9 is 185 b9
    M-: is 186 ba
    M-; is 187 bb
    M-< is 188 bc
    M-= is 189 bd
    M-> is 190 be
    M-? is 191 bf
    M-@ is 192 c0
    M-A is 193 c1
    M-B is 194 c2
    M-C is 195 c3
    M-D is 196 c4
    M-E is 197 c5
    M-F is 198 c6
    M-G is 199 c7
    M-H is 200 c8
    M-I is 201 c9
    M-J is 202 ca
    M-K is 203 cb
    M-L is 204 cc
    M-M is 205 cd
    M-N is 206 ce
    M-O is 207 cf
    M-P is 208 d0
    M-Q is 209 d1
    M-R is 210 d2
    M-S is 211 d3
    M-T is 212 d4
    M-U is 213 d5
    M-V is 214 d6
    M-W is 215 d7
    M-X is 216 d8
    M-Y is 217 d9
    M-Z is 218 da
    M-[ is 219 db
    M-\ is 220 dc
    M-] is 221 dd
    M-^ is 222 de
    M-_ is 223 df
    M-` is 224 e0
    M-a is 225 e1
    M-b is 226 e2
    M-c is 227 e3
    M-d is 228 e4
    M-e is 229 e5
    M-f is 230 e6
    M-g is 231 e7
    M-h is 232 e8
    M-i is 233 e9
    M-j is 234 ea
    M-k is 235 eb
    M-l is 236 ec
    M-m is 237 ed
    M-n is 238 ee
    M-o is 239 ef
    M-p is 240 f0
    M-q is 241 f1
    M-r is 242 f2
    M-s is 243 f3
    M-t is 244 f4
    M-u is 245 f5
    M-v is 246 f6
    M-w is 247 f7
    M-x is 248 f8
    M-y is 249 f9
    M-z is 250 fa
    M-{ is 251 fb
    M-| is 252 fc
    M-} is 253 fd
    M-~ is 254 fe
    M-^? is 255 ff