[NTLUG:Discuss] Linux sort
Robert Citek
robert.citek at gmail.com
Mon Apr 21 12:58:11 CDT 2008
On Mon, Apr 21, 2008 at 12:24 AM, Leroy Tennison
<leroy_tennison at prodigy.net> wrote:
> How do you sort a tab-delimited file using sort? Created the following
> test file (named test):
>
> five zzzzz 5
> Four vcxvbc 3
> one asdf 4
> three ghjks 1
> Two qwerty 2
>
> (those are tabs separating the text, I checked with hexdump)
You can use the -A option to cat to display control characters:
$ echo -e 'a\tb' | cat -A
a^Ib$
> I've tried
>
> sort -t\t -k3,3 test
> sort -t\t -k3n,3 test
> sort -t '9' -k3,3 test
> sort -t '\9' -k3,3 test (Produces a "multi-byte tab" error message)
In bash:
$ echo -e 'five\tzzzzz\t5
Four\tvcxvbc\t3
one\tasdf\t4
three\tghjks\t1
Two\tqwerty\t2' |
sort -t$'\t' -k 3,3n
Regards,
- Robert
More information about the Discuss
mailing list