Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Control+T in Terminal shows time snapshot' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Control+T in Terminal shows time snapshot
Authored by: pauljlucas on Jan 27, '12 10:59:34AM
Control-M and Control-J create a CR or LF (nominally respectively, though I'm not sure what the practical difference is here).
There is no difference. In ASCII, Control-M (also written ^M) is CR and Control-J (^J) is LF. For example, a pure Unix terminal program can't tell the difference between you typing ^M vs return.
Control-V followed by another letter lets you type other control characters in.
That's more to do with the command-line editor you're currently using than the shell, i.e., that's what you type in vi.
- Paul

[ Reply to This | # ]
Control+T in Terminal shows time snapshot
Authored by: fido on Jan 28, '12 07:46:13AM
Any Unix program can see the CR's and LF's separately if the programmer chooses. They just have to turn off icrnl or put the tty into raw mode. To say that there is no difference between the two is a little misleading.


stty -icrnl
echo "Type something, hit control M or enter/return a few times, then hit control J"
read ans
echo "You typed:"
echo $ans | od -a
stty icrnl
Also, control V is the usual setting for the tty's "literal next" (lnext) setting and is not limited to command line editors. Try running a simple command like sleep 30, then hit ^V^M and ^V^J to see that there is a difference between the two.

In Terminal the key labelled "return" will produce the same results as hitting ^M because they're both ways to generate a carriage return (CR). If icrnl is on (see stty -e) then these will be mapped to newlines.

[ Reply to This | # ]