When sorting why is 1<tab> greater than 12<tab>?

Viewed 33

Here is the content of file.txt

A5RS12 <tab> R
A5RS1  <tab> R

That is, the string A5RS12 then a tab then the character R. On the next line, the string A5RS1 then a tab then the character R.

I ran the sort command:

sort -t '<ctrl-v> <tab>' -k 1 file.txt > out.txt

Here is out.txt:

A5RS12 <tab> R
A5RS1  <tab> R

No change to the order of the lines!

Later, I used the join command to join out.txt with another file. The join command generated an error message saying that out.txt is not sorted.

How do I sort file.txt so that it produces this ordering:

A5RS1   <tab> R
A5RS12  <tab> R

I am using Fedora 36.

0 Answers
Related