I need to convert file1 is such way that it has three words in each line, where first is second word from line starting with 'ROBO' and second word is second word from line starting with '1)' and finally third word is fourth word from from line starting with '1)'. See example below...
$cat file1
ROBO lab1 - Topology:
1) 10.195.41.1 10.195.41.255 comment1
ROBO lab2 - Topology:
1) 10.95.4.1 10.95.4.254 comment2
to :
lab1 10.195.41.1 comment1
lab2 10.95.4.1 comment2
I ended up with the following:
sed 'N;s/\n/ /' file1| awk '{ if ($6 ~ /^10\./) print $2 " " $6}'
but it breaks when I have something like this:
ROBO lab1 - Topology:
ROBO lab1 - Topology:
1) 10.195.41.1 10.195.41.255 comment1
ROBO lab2 - Topology:
1) 10.95.4.1
I need to control that first line starts with 'ROBO' and second starts with '1)' and move down the file if not..until I meet the right pair
1)
-lines tab separated? – Kusalananda♦ Sep 12 '17 at 19:38