Posts

Showing posts from September, 2020

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