How to sort the contents of a file in linux
I have a file in a path /tmp which contains some rpm packages. I need to sort the file.
ll /tmp/pckg.txt
sort /tmp/pckg.txt > /tmp/s_pckg.txt
A new file /tmp/s_pckg.txt will be created and the contents in that file will be in sorted order.
sort -r /tmp/pckg.txt > /tmp/s_pckg.txt
Reverse sorted.
sort -nk2 /tmp/s_pckg.txt
On the basis of second column it will sort.
I have a file in a path /tmp which contains some rpm packages. I need to sort the file.
ll /tmp/pckg.txt
sort /tmp/pckg.txt > /tmp/s_pckg.txt
A new file /tmp/s_pckg.txt will be created and the contents in that file will be in sorted order.
sort -r /tmp/pckg.txt > /tmp/s_pckg.txt
Reverse sorted.
sort -nk2 /tmp/s_pckg.txt
On the basis of second column it will sort.
No comments:
Post a Comment