Unix sort with tab-delimited fields

There are things I do fairly often, but not often enough to actually remember how. One such is sorting a file with tab-delimited fields. I always expect to be able to do this:

sort -t"\t" -k3 ...

but that doesn’t work. The shell does not recognise “\t” as tab.

For future reference, a workaround is to use a perl wrapper:

perl -we 'print `sort -t"\t" -k3 ...`'

which works because perl substitutes a tab for \t

1 Response to “Unix sort with tab-delimited fields”


  1. 1 Mal May 26, 2009 at 8:33 am

    Tis all Greek to me ;)


Leave a Reply




 

May 2009
M T W T F S S
« Apr   Jun »
 123
45678910
11121314151617
18192021222324
25262728293031

Flickr Photos

Your call is important to us

Supernova

Body & Soul exhibition opening

More Photos

My bookmarks