I have Files where the Number of Columns are dynamic and different files can have different number of Columns.
But among those Files i have a Common Objective from which i need to remove the 1st Column and the last 2 Column always from all the Files.
So i am trying to write a generic statement which can fit for all Files having different number of columns.
I am able to Remove the 1st Column using cut but got stuck how to write a statement to remove the last 2 Columns.
cat file1.dat | cut -d "|" -f 2-
The Above command removes the First Column. But not able to write a generic command to remove the last 2 columns when the number of columns are different for different files.