read a file and compare

hi

how can i read a file using the unix script and check for one or more field value for a predefined status/value

for example : the file contains the following text

Name IP Address/Mask Type Connection Status

mgmt-eth0(1) 10.7.225.5/24 mgmt Ethernet Up

lo1(1) 127.0.0.1/8 mgmt Loopback Up

i need to check the status column value whether it is Up. if its not it has to be logged in a separate file.

thanks

for line in `cat $file`
do
statusfield=`echo $line | tr -s " " | cut -d " " -f5`
if [ $statusfield = "up" ]
then
echo " system is up"
else 
----

fi
done


I'm sorry, but that's pretty tortured.

awk 'NR==1 || $5 == "Up" { next; } { print }' file

Is the status field always the fifth field? What's there when it's not up? Are there supposed to be empty lines between the records? Is it okay to simply ignore the header line? (I have made reasonable assumptions to all of these in the above script, but feel free to check those assumptions. Respectively: yes, anything or nothing, no, yes.)