How to print all columns except first column in Linux bash shell ?
Today in this article, we will look at an interesting tip to print all columns of a file except first.
Lets look the command stepwise to understand how it works.
1. Printing all columns: Normal command output
[root@ngelinux01 ~]# rpm -qa --last | head -1 jre1.8-1.8.0_281-fcs.x86_64 Wed 14 Apr 2021 12:24:37 BST ### To get specific column data using awk. [root@ngelinux01 ~]# rpm -qa --last | head -1 | awk '{print $2}' Wed
Now suppose you want to omit first column and print complete data which comprises in next 6 columns, or it might be any number of columns.
2. Omit first Column and print rest of columns.
[root@ngelinux01 ~]# rpm -qa --last | head -1 | awk '{$1="";print}' Wed 14 Apr 2021 12:24:37 BST
In the above output, we can see that the first column is set to null, or empty character and then whole output gets printed.
This helps us to omit the first column.
This is one of the easiest trick to achieve this task using awk command.