Start a Conversation

Unsolved

R

2 Posts

308

January 30th, 2021 05:00

Linux sorting the files seperated with '|' character

I am having troubles with sorting in the Linux. First time evr using it. So I have file named testfile with the following info:

AAA BBB | 45
Jake | 36
Sam Sam | 40
How can I sort testfile by the numeric value? I have tried to use this:

sort -k 2n tesfile
But it did not helped tried to cut the file till the '|' character and then sort also did not helped. I also tried -t key in sort, but seems like it does not work too.

sort -t"|", -k 1n testfile

January 30th, 2021 08:00

It seems that you want to sort by the last column. If it is the case, look at:

https://unix.stackexchange.com/questions/10524/how-to-numerical-sort-by-last-column

No Events found!

Top