Code:
# Script: test.sh
firstW=0
while IFS=":" read field1 field2 field3 field4
do
if [ "${field1:0:1}" == "#" ]; then
continue
fi
if [ "$field4" = " W" ]
then
firstW=1
fi
if [ $firstW -eq 1 ]
then
echo $field1 is $field2 and $field3
fi
done <t
You will have to test whether field4 has a leading space since IFS is set to colon.