bash script help?

Knute Johnson ubuntu at knutejohnson.com
Mon Nov 14 05:40:47 UTC 2011


I've got a bash script that I run in cron.daily to backup some data to a 
jump drive.  One of the commands in my script is to umount the drive. 
If I write;

if umount /dev/sdb1; then
     #do something
fi

it always does it even if the umount is successful.  But if I write;

umount /dev/sdb1
if [ $? -ne 0 ]; then
     #do something
fi

it works as I expect and doesn't do the code in the if.  mount seems to 
work as I expect but something is different about umount or I don't 
understand what I'm doing :-).

Thanks,

-- 

Knute Johnson




More information about the ubuntu-users mailing list