For example, I wanted to use the sort utility with the -t option to specify tab separators, but
sort -t "\t"
doesn't work.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.
Sign up to join this communityFor example, I wanted to use the sort utility with the -t option to specify tab separators, but
sort -t "\t"
doesn't work.
Don't use double quotes.
sort -t $'\t'
Or I think Ctrl V inserts a Tab??
Edit:
http://www.gnu.org/s/bash/manual/html_node/ANSI_002dC-Quoting.html#ANSI_002dC-Quoting
$'...'
trick, though; now I've learned something new. :-)
$' '
. It allows you to enter a string, but also have escaped characters. Double quoting literally prints \t
If you leave off the quotes you get a tab character.
Try Control-v, then Tab. If you see the cursor tab over to the right, it worked.
According to the comment by Mark you can also try Control-v and then Control-i.
sort -t " "
(with the literal tab as described above) and it worked for me.
First press Ctr
+ v
and
Then press tab
key.
Using above mentioned step adding tab
Reference: https://linuxjourney.com/lesson/cut-command
You can also use printf:
sort -t "$(printf "\t")"
Not like $'\t'
, printf
use double quotes which allow you to use environment variables, like below:
char="\t" # any source just plain text
sort -t "$(printf "$char")"
Single quote is static and not flexible, though it's simple, you can choose based on your requirement.