Hi,
How do you swap two rows in a space delimited text file? Thanks!
Hi,
How do you swap two rows in a space delimited text file? Thanks!
Hi
Please post your sample input file and expected output file to give us some clarity.
Guru.
Input:
1334 NA12146 0 0 1 -9 G A A G C A G G
1347 NA11882 0 0 2 -9 G A A G C A G G A
1340 NA07056 0 0 2 -9 G A A G A A G G
1408 NA12154 0 0 1 -9 A A G G A A G G
Swap lines 2 and 3
Output:
1334 NA12146 0 0 1 -9 G A A G C A G G
1340 NA07056 0 0 2 -9 G A A G A A G G
1347 NA11882 0 0 2 -9 G A A G C A G G A
1408 NA12154 0 0 1 -9 A A G G A A G G
Hi
$ awk 'NR==2{x=$0;getline;print;$0=x;}1' file
1334 NA12146 0 0 1 -9 G A A G C A G G
1340 NA07056 0 0 2 -9 G A A G A A G G
1347 NA11882 0 0 2 -9 G A A G C A G G A
1408 NA12154 0 0 1 -9 A A G G A A G G
Guru.
@Guru, Can you explain above command