Bash sorting 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 by the third field, the command returns an error

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

I am also trying to use

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

but the command returns the same error.

Any idea what to do?

+4
source share
2 answers

The parameter -texpects a single separator character, but you give it two. The way to do what you want will be to assume that there is only one separator ;, and therefore the third column will become the fifth:

sort -t ';' -k 5 -r -n -o output.txt input.txt
+5
source

-t , , , , (), . , "," , | (pipe), , "," .

+2

Source: https://habr.com/ru/post/1547254/


All Articles