On Tue, 18 Nov 2008, JC Janos wrote: > I'm writing a script to manage a number of ipsets. > > How can I script (bash/perl) a check to see if: > > an IPSET exists > an existing IPSET is EMPTY or not There are multiple ways to do it, even in bash ;-) # Check that a set exists in bash: ipset -L foo >/dev/null 2>&1 if [ $? -ne 0 ]; then echo "Set foo does not exist." fi # Check that an existing set is empty: if [ -z "`ipset -L foo 2>/dev/null | \ awk '{ if (FNR == 7) print $0 }'| \ grep Bindings:`" ]; then echo "Set foo is empty." fi Best regards, Jozsef - E-mail : kadlec@xxxxxxxxxxxxxxxxx, kadlec@xxxxxxxxxxxx PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt Address : KFKI Research Institute for Particle and Nuclear Physics H-1525 Budapest 114, POB. 49, Hungary -- To unsubscribe from this list: send the line "unsubscribe netfilter" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html