Friday 15 February 2013

unix - Grep "DOWN" states in a log file and add a variable on to the line -



unix - Grep "DOWN" states in a log file and add a variable on to the line -

i have tables in log file. looking way grab out lines , add together sentence behind relating server downwards in within unix box. possible ?

if utilize command can downs on table "grep downwards file" want mdserver downwards @ also. first thought utilize -b switch in grep this. isn't going work mdserver* can't expected lines above "down" item. suggestions ? give thanks you.

my table in log file mdserver10 corn 0 0 bacon 54 0 water downwards 0 0 fries 746 0 turkey 0 mdserver11 water downwards 0 0 fries 746 0 turkey 0 mdserver12 corn downwards 0 0 bacon 54 0 water 0 0 fries 746 0

my expected results.

water downwards 0 0 downwards on mdserver10 water downwards 0 0 downwards on mdserver11 corn downwards 0 0 downwards on mdnserver12 </table><table border="1" style="width:300px">mdserver10 </tr> <tr><td style="width:310px"> water </td><td bgcolor ="red"> downwards </td><td style="width:50px"> 0 </td><td style="width:50px"> </tr> </td></tr>

$ awk 'nf==1{srvr=$0; next} /down/{print $0, "is downwards on", srvr}' file water downwards 0 0 downwards on mdserver10 water downwards 0 0 downwards on mdserver11 corn downwards 0 0 downwards on mdserver12

unix awk sed grep

No comments:

Post a Comment