tab character in linux
May 3, 2005 11:43 AM
how do i print a tab character
Hi,
i don't normally use this resource for technical issues i can't solve (or i try not to) but this is proving annoying. I've spent too long working on this as it is. I am sshing to a linux box from a windows machine.
i am trying to sort a file by the last column of a text file. each row is seperated by tabs. my problem is that to use sort with tabs as the field, i actually need to type a tab character. However I can't seem to type a tab character, i think the shell won't let me. I can type tab to finish a command or file name, but i can't actually type a tab. I can type a tab in vi or emacs, but just not in the shell.
so what do i do?
sort doesn't want \t or ^l , it wants a tab.
so my question is: what is going on here, how do i work around this?
Hi,
i don't normally use this resource for technical issues i can't solve (or i try not to) but this is proving annoying. I've spent too long working on this as it is. I am sshing to a linux box from a windows machine.
i am trying to sort a file by the last column of a text file. each row is seperated by tabs. my problem is that to use sort with tabs as the field, i actually need to type a tab character. However I can't seem to type a tab character, i think the shell won't let me. I can type tab to finish a command or file name, but i can't actually type a tab. I can type a tab in vi or emacs, but just not in the shell.
so what do i do?
sort doesn't want \t or ^l , it wants a tab.
so my question is: what is going on here, how do i work around this?
sort doesn't want \t or ^l , it wants a tab.
It'll work just fine (and be a lot less confusing to look at) if you do:
posted by grouse at 12:35 PM on May 3, 2005
It'll work just fine (and be a lot less confusing to look at) if you do:
- sort -t \t
- sort -t $'\t'
- sort -t "\t"
- sort -t '\t'
posted by grouse at 12:35 PM on May 3, 2005
fleacircus: "
In the bash man page, under the heading "Commands for Changing Text", is this:
tab-insert (C-v TAB)
Insert a tab character.
Searching the man page for \btab\b would have got you to it in not too long.
Right before that is the more generic:
quoted-insert (C-q, C-v)
Add the next character typed to the line verbatim. This is how to insert characters like C-q, for example.
posted by Plutor at 12:38 PM on May 3, 2005
man bash
+ 2-3 hours"In the bash man page, under the heading "Commands for Changing Text", is this:
tab-insert (C-v TAB)
Insert a tab character.
Searching the man page for \btab\b would have got you to it in not too long.
Right before that is the more generic:
quoted-insert (C-q, C-v)
Add the next character typed to the line verbatim. This is how to insert characters like C-q, for example.
posted by Plutor at 12:38 PM on May 3, 2005
how would i figure this out on my own?
Google for "linux insert literal tab" would've got results, FWIW. (Not jumping on you for not searching Google -- just answering the question, in case the word "literal" hadn't come to mind.)
Incidentally, tab and ^I are identical. The key marked "tab" sends ^I, just like the key marked "backspace" sends ^H (or maybe ^? if it's mapped to "delete") and the key marked "Enter" sends ^M.
posted by mendel at 12:45 PM on May 3, 2005
Google for "linux insert literal tab" would've got results, FWIW. (Not jumping on you for not searching Google -- just answering the question, in case the word "literal" hadn't come to mind.)
Incidentally, tab and ^I are identical. The key marked "tab" sends ^I, just like the key marked "backspace" sends ^H (or maybe ^? if it's mapped to "delete") and the key marked "Enter" sends ^M.
posted by mendel at 12:45 PM on May 3, 2005
i spent a lot of time googling and all i could find out about was using tab to complete commands. i tried using term literal i think.
grouse i think you are wrong. as far as I can tell sort will not accept anything like that.
thanks all for the help.
posted by alkupe at 1:16 PM on May 3, 2005
grouse i think you are wrong. as far as I can tell sort will not accept anything like that.
thanks all for the help.
posted by alkupe at 1:16 PM on May 3, 2005
Save yourself the 2-3 hours
man bash | col -b | grep tab
Or, you know, if you use a proper computer
man bash | col -b | bbedit
Then use the Find command (-:
posted by alana at 1:24 PM on May 3, 2005
man bash | col -b | grep tab
Or, you know, if you use a proper computer
man bash | col -b | bbedit
Then use the Find command (-:
posted by alana at 1:24 PM on May 3, 2005
alkupe: Given that in bash, $'\t' sends exactly the same argv to the executed program as Ctrl-v, Ctrl-i, it's really hard to believe that that doesn't work. In fact, I just tested it and it does.
posted by grouse at 1:38 PM on May 3, 2005
posted by grouse at 1:38 PM on May 3, 2005
It does what I just said it does. Try searching for $' in the man pages for bash.
posted by grouse at 2:14 PM on May 3, 2005
posted by grouse at 2:14 PM on May 3, 2005
This thread is closed to new comments.
posted by moz at 11:50 AM on May 3, 2005