Reputation: 1687
I have a linux file whose content is as below:
hey this
is just
sample file
I want to :
1. sort the three lines according to the second word so the output should be :
sample file
is just
hey this
2. sort the three lines according to the second character of second line, so the output would be :
hey this
sample file
is just
Is there anyway i can run a perl/unix command on command line(doesnt matter using pipes)?
Upvotes: 3
Views: 5049
Reputation: 1687
I got the answer for both the questions:
For sorting by second word: sort -k2 myfile
For sorting by second character of second word sort -k2.3 myfile
Upvotes: 5