MyBB Community Forums

Full Version: help with awk statement in Linux
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
this is not working for me

tail -n50 kern.log | gawk '{ IF ( $8 == "CIFS" ) print "start"}'

I get a syntax error at the start of the print statement. I have tried wrapping it in braces, adding a semi-colon, etc to no avail.

Anyone have an idea? This is the start of a more complex one line if-elseif command I need to build, but for some reason this is not working.

actually here is the if-elseif I am starting with

tail -n50 kern.log | awk '{ IF ( $8 == "CIFS" ) { print "Start"; } ELSE IF ( $8 == "wlan0" ) { print "Stop"; } }'
Will this work? No more syntax errors for me:
tail -n50 kern.log | awk '{ if ( $8 == "CIFS" ) print "Start"; else if ( $8 == "wlan0" ) print "Stop"; }' 
IF -> if etc.
well that was stupid simple. thanks guys. now i need to finish up the rest of it.