help with she script

fbsd_user fbsd_user at a1poweruser.com
Sun Jul 3 20:47:31 GMT 2005


Thanks guys your solutions have worked and I am learning allot along
the way.

This is my last coding problem.


target="check-state"

# Find the rule number of the target rule where you want the doorman
# pass rules inserted before.

ruleno=`ipfw list | sed -n -e "s/00\([0-9]*\) $target/\1/p"`

The output of 'ipfw list' looks like this

nnnnn  a 5 position sequence rule number
blank  followed by a empty single position
x-x    a 10 to 80 position rule text


When the rule text matches the target text I want the
first 5 position rule number to go into ruleno.

Large rules files may use all 5 positions and then
the above code will fail to get the rule number.
Tried to remove the s/00\ but had syntax problems.






More information about the freebsd-questions mailing list