1

Swap of fields dynamically

view story
linux-howto

http://www.unix.com – Dear Friends, I have file a.txt Code: 1|2|3|4|5|6|7|8 a|b|c|d|e|f|g|h i am using the below code to swap the fields in file Code: awk -F\| '{print $5,$1,$2,$3,$4,$6,$7,$8}' OFS=\| a.txt > output.txt output.txt Code: 5|1|2|3|4|6|7|8 e|a|b|c|d|f|g|h The above command is working fine. I am trying make it dynamic for swpping the field.I am struck where and how to start .My inputs should be the which column should come in first field and rest moving other side .Please find example for the above file Code: Swapfields.sh a.txt 5 8 5= First field in putputfile 8=numbe (HowTos)