Код: Выделить всё
/sbin/ipfw list | grep -i "allow ip from 172.16.87.240" | grep -i "to any" | awk '{print $1}'
Код: Выделить всё
/sbin/ipfw list | grep -i "allow ip from to any" | grep -i "172.16.87.240" | awk '{print $1}'
Немного подумала и решила переделать вот так:
Код: Выделить всё
/sbin/ipfw list | grep -i "allow ip from any to 172.16.87.240" | awk '{print $1}'

Это я решила провести тесты в командной строке, а вообще исходный полурабочий файл вот такой:
Код: Выделить всё
#!/bin/sh
#file, that will turn on virtual groups access to network resources
#(input args: login, password, segment, mask) ex: test password 192.168.0.0 255.255.255.0
# For ipfw ONLY !!!
#OFF
CHECKIP="grep -e ^[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}$";
echo $3 | $CHECKIP >/dev/null 2>&1 && echo $4 | $CHECKIP >/dev/null 2>&1 || exit 0
if test $4 = 255.255.255.255
then
M=" ";
else
M="/";
fi;
for NUM in `/sbin/ipfw list | grep -i "allow ip from $3$M" | grep -i "to any" | awk '{print $1}'`;
#for NUM in `/sbin/ipfw list | grep -i "allow ip from any to" | grep -i "$3$M" | awk '{print $2}'`;
do
/sbin/ipfw delete $NUM;
done;
exit 0;