user59036
user59036

Reputation: 203

move second last column to first using awk

I would like do the following using awk:

The file use tab as field separator

Example of my input with the header and the first row of data

"Column1" "Column2" "Column3" "Column4" "Column5" 

  "a1"      "b2"      "c3"       "d4"      "e5"

Desired output

"Column4" "Column1" "Column2" "Column3"  "Column5" 

  "d4"      "a1"      "b2"      "c3"       "e5"

Upvotes: 1

Views: 120

Answers (1)

suspectus
suspectus

Reputation: 17258

Just need to arrange the fields in the desired order:

awk '{print $4, $1, $2, $3, $5}' your-file

Upvotes: 1

Related Questions