Tuesday, November 20, 2007

using tab as field separator while using sort command in bash shell

It was some what strange to me when I experienced that tab as field separator is not supported (not exactly supported. but didn't make it easy to use) in sort command in bash shell. Probably it depends on sort version. But, some how it didn't work in my machine.

The error that I got when I included tab as field separator is:
sort: multi-character tab '\t'

So, after doing search over the above error,here is one of the solutions that worked for me:
TAB=$(printf "\t")
and then using sort -t "$TAB".
For ex:
sort -t "$TAB" -k2,2 -n entries.txt

1 comment:

Ray Dehler said...

Thanks, that worked :)