I am looking for a way to ignore the first two lines of a file and flip ips / dns in everything after the second line. Please note that I am the sed removefirst line (which is the header).
bash-4.4$ less test
1 #remove
2 #comment 1
3 #comment 2
4 foo 127.0.0.1
5 bar 127.0.0.1
the results I'm looking for
bash-4.4$ less test-fixed
1 #comment 1
2 #comment 2
3 127.0.0.1 foo
4 127.0.0.1 bar
command channel I tried:
FILE=/tmp/test ; sed '1d' $FILE | awk 'NR>2 { t = $1; $1 = $2; $2 = t; print; } ' >| /tmp/test-fixed
obviously the NR>2sequence number of the current record is skipped to line 3, so I think I need an iteration loop to print, but it doesn't work until N3it is reached? Not sure...
ehime source
share