The first time I truly utilized cat -v was when I needed to know a certain keys in a terminal emulator, for example Shift+Left:
$ cat -v
^[[1;2D
-v will show those non-printing characters, using ^ for control and M- for alt as notations, except for LFD (Line Feed) and TAB (Tab Key). In that special exception, hexdump or od can help, or you can use -T (--show-tabs) for tabs:
$ echo -ne '\t\n' | cat -v
$ echo -ne '\t\n' | cat -vT
^I
$ echo -ne '\t\n' | hexdump
0000000 0a09
0000002
$ echo -ne '\t\n' | od -c
0000000 \t \n
0000002
I found it’s not only helpful for troubleshooting key control characters, but also for finding out what exactly does tput output to terminal, for example:
$ tput clear | cat -v
^[[H^[[J
$ tput reset | cat -v
^[c^[[?1000l^[[?25h
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.