In this tutorial, How to change the order of columns in the output of `uniq -c` command. I use read the file and show the unique Name from the file. How many time this name of the file?
The content of file as example below
[[email protected] ~]$ cat devopsroles.txt
huu
huu
phan
van
dev
devopsroles
dev
huu
huu
I use awk, sort uniq command to read file and show the unique Name as example below
[[email protected] ~]$ cat devopsroles.txt | awk '{print $1}' | sort | uniq -c | sort -nr4 huu2 dev1 van1 phan1 devopsroles
Now, How to change the order of columns in the output of file
[[email protected] ~]$ cat devopsroles.txt | awk '{print $1}' | sort | uniq -c | sort -nr | awk '{ print $2,$1}'huu 4dev 2van 1phan 1devopsroles 1[[email protected] ~]$ cat devopsroles.txt | awk '{print $1}' | sort | uniq -c | sort -nr | awk '{ print $1,$2}'4 huu2 dev1 van1 phan1 devopsroles
Conclusion
How to change the order of columns in the output in file linux. I hope will this your helpful. Thank you for reading the Huuphan.com page!
Thanks for reading How to change the order of columns in the output My blog Zimbra Mail Server,linux,bash script,centos,linux command I hope this is useful.