This short one just in,
A lot of times, you might need to specify a control character (like ctl-c, for instance) in a file or on the command line.
A common instance of this is when you need to set your backspace key as the erase key using stty in most shells.
Some folks, rightfully, assume that you can put that in your .profile as - literal - ^H - That's the way it looks when you hit the backspace key.
Unfortunately, the shell reads this as caret (^) H, and not the actual backspace key. The trick here is to print the actual control key sequence. This can be done very easily by doing the following:
1. Type ctl-v
2. Hit your backspace key
And there's your ^H - except it's real this time :) Your line, in vi, will look like: stty erase ^H
One easy way to tell if you've accurately captured a control key sequence in a file is to run "cat" on the file. Doing this, if you've actually captured the control key sequence, won't show you anything in the place of the ^H. If you still want to see it, just to be sure, use "cat -v" instead.
Best wishes,
, Mike
linux unix internet technology
Sunday, October 28, 2007
How to Really Represent Control Characters
Posted by Mike Golvach at 11:19 PM
administration, advice, caret, control characters, ctl, ctl-v, linux, scripting, stty, technology, tips, tricks, unix