Hello everyone,
I have written simple script below to check if ip is added to interface
#!/usr/local/bin/bash
IFCONFIG="/sbin/ifconfig"
SERVICE="/usr/sbin/service"
IP="79.137.X.X"
GREP=$(${IFCONFIG} | grep ${IP})
ip_quantity_check () {
echo ${GREP} | wc -l
}
if [[ ip_quantity_check -gt 0 ]]; then
echo "IP is linked"
else
echo "Nie jest"
exit 1
fi
When i use only ip_quantity_check function im getting "1" as should be and this is ok. But when i put function into the test "[[ ]]", im getting some wrong interpretation of it becouse i always get:
else
echo "Nie jest"
Where is a problem ?
Thank you,