Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash sort and multi-character tab error

I have data in the following form

C1510438;;C0220832;;2
C0026030;;C0034693;;1
C1257960;;C0007452;;1
C0061461;;C0027922;;2
C0011744;;C0037494;;3
C0014180;;C0034493;;3

When I try to sort on the 3rd field, the command returns the error

sort -t ';;' -k 3 -r -n -o output.txt input.txt
sort: multi-character tab `;;'

I also try with

sort -t $';;' -k 3 -r -n -o output.txt input.txt

but the command returns same error.

Any idea what to do?

like image 782
Andrej Avatar asked Jul 05 '14 15:07

Andrej


1 Answers

The -t option expects a single separator character, but you give it two. A way to do what you want would be to consider that the separator is only a single ;, and thus the third column would become the fifth one:

sort -t ';' -k 5 -r -n -o output.txt input.txt
like image 174
julienc Avatar answered Sep 28 '22 16:09

julienc