0

I want to sort only rows in my file e.g

5 2
2 1

and I want to have an output like this

2 5
1 2

Could someone help me ?

1 Answers1

3

You could do it fairly simply with perl, if your fields are whitespace separated. Assuming you want to sort in numeric (rather than lexical) order:

$ perl -alne 'print join " ", sort {$a <=> $b} @F' file
2 5
1 2
steeldriver
  • 142,475