Here you go.....
mount | grep -q home HOMESTATUS=$? mount | grep -q backup BACKUPSTATUS=$?
if [ $HOMESTATUS -eq 0 -a $BACKUPSTATUS -eq 0 ]; then echo "You got both man, do your thing..." exit 0; else echo "Error -- either home or backup missing -- Or is it BOTH !%$!!@#%!" exit 1; fi
Regards R. K. Rajeev
P.S. : Dont rely too much on mtab, a read only filesystem situation might mean you have old/stale data in it, always pipe live mount command or use /proc/mounts.
On 26 February 2013 23:45, gnulinuxist@gmail.com gnulinuxist@gmail.com wrote:
Hello,
I am using a script where I check if /home and /backup are present in /etc/mtab but can't manage the 'and' operator in grep. Currently I use the 'if grep -q "/home" ; then ......... then I do 'fi' and again 'if grep -q "/backup" to finally go to my commands. I tried to make grep do the AND combo but got errors as it works only on one line. I want my command to start only if both /home and /backup are present in mtab. With my dual check method it works, but I want a clean lean script.
Regards, Rony. -- http://mm.ilug-bom.org.in/mailman/listinfo/linuxers