Shell commands do not use a consistent syntax, especially the older ones like "sort". The "\t" is a meta-character, in other words it represents a tab. "sort" is looking for a literal "tab". So what you need to do is press the "tab" key instead of typing a backslash and the letter "t". This does not work on the bash command line because file name completion is turned on by default and I don't know how to temporarily turn it off. Generally one does not do much shell programming on the command line though, and so the "sort" line would be in a file. I named mine x.sh: $ cat x.sh sort -t " " -k 2 tab.txt Your work-around is very clever though! BTW I suggest using the $(command) syntax instead of back-ticks since the latter is so difficult to see. I'm so happy that I can finally answer a question! :-) Rick Tom Penney wrote: > Here is a good one for the group. I've found a workaround so waste too > much time on this. > > I'm trying to sort a text file using tab as a field separator. sort > allows you to sort by a field with -k. The default field separator is > whitespace, I need tabs. Sort allows you to set the field separator with > -t, however it chokes when you tell it to use "\t". Observe: > > [tomp at lotsa sort]$ cat tab.txt > 1 cherry > 2 orange > 3 grape > 4 apple > 5 mango > [tomp at lotsa sort]$ sort -t "\t" -k 2 tab.txt > sorted.txt > sort: multi-character tab `\t' > [tomp at lotsa sort]$ cat sorted.txt > > It's an empty file. > I did found a workaround (those are back-ticks not single quotes) > > [tomp at lotsa sort]$ TAB=`echo -e "\t"` > [tomp at lotsa sort]$ sort -t "$TAB" -k 2 tab.txt > sorted.txt > [tomp at lotsa sort]$ cat sorted.txt > 4 apple > 1 cherry > 3 grape > 5 mango > 2 orange > > according to google this works as expected in Unix but not in linux. > http://www.mail-archive.com/bug-textutils@gnu.org/msg00833.html > > Does anyone know why I can't use "\t" in sort to set a tab? > -- Eric (Rick) Meyerhoff _______________________________________________ TCLUG Mailing List - Minneapolis/St. Paul, Minnesota http://www.mn-linux.org tclug-list at mn-linux.org https://mailman.real-time.com/mailman/listinfo/tclug-list