How to change the order of columns in the output
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
[HuuPV@DevopsRoles ~]$ 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
[HuuPV@DevopsRoles ~]$ 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
[HuuPV@DevopsRoles ~]$ cat devopsroles.txt | awk '{print $1}' | sort | uniq -c | sort -nr | awk '{ print $2,$1}'huu 4dev 2van 1phan 1devopsroles 1[HuuPV@DevopsRoles ~]$ 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!
Comments
Post a Comment