using grep for formatting.
Hi,
I have a raw-output.log file as follows: spawn ssh xxxxxxxx@1.1.1.1 1.1.1.1 ============= ******************************************************************* * This is test * * * * Contact IT * * * ******************************************************************* Router-101#sh run | i _email_to event manager environment _email_to noc-group-101@yyy.com Router-101#exit Connection to 1.1.1.1 closed by remote host. Connection to 1.1.1.1 closed. spawn ssh xxxxxxxx@2.2.2.2 2.2.2.2 ============= ******************************************************************* * This is test * * * * Contact IT * * * ******************************************************************* Router-202#sh run | i _email_to event manager environment _email_to noc-group-202@yyy.com Router-202#exit Connection to 2.2.2.2 closed by remote host. Connection to 2.2.2.2 closed. I need the exact following output: 1.1.1.1 ============= event manager environment _email_to noc-group-101@yyy.com 2.2.2.2 ============= event manager environment _email_to noc-group-202@yyy.com How do i get this using grep or other methods. Any help will be appreciate. Thank you. KM |
You could use this sed line:
Code:
sed -n -e /^[0-9].[0-9].[0-9].[0-9]/,/===/p -e /event/p yourfile.txt Code:
1.1.1.1 Code:
sed -n -e /^[0-9].[0-9].[0-9].[0-9]/,/===/p -e /event/p yourfile.txt > newfile.txt |
Hi, something like this?
Code:
awk 'BEGIN{FS="\n";RS="closed.\n"} {print $2;print $3;for (i=3;i<=NF;i++){if($i~/event manager/){print $i}};print ""}' ~/tmp4/routers. Cheers, Tink P.S.: Too slow :} ... and the sed one is prettier. |
All times are GMT -5. The time now is 11:36 AM. |