Urgent help on sorting

Hello Everyone, I need urgent help here . I need to sort a file for one of my requirement , The file has to be sorted using a key with 4 columns. Sorting is working fine on those 4 columns but when the key is matching for many rows the other columns are also getting sorted which is not required .

Giving an example here : File = Input.txt
1 101 100
1 001 200
1 002 100

Here I am using below command to sort.

Sort -k1,1 -k3 Input.txt

This gives me below output:
1 002 100
1 101 100
1 001 200

I don't want to sort the second column here . I have tried with -s option for stable sort but the same is not supported .

Please help.

Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

1 Like