How to check if a filesystem is mounted with a script

view full story

http://unix.stackexchange.com – I am new at scripting ... I can do very basic stuff, but now I need a hand. I have a local filesystem that only will be mounted when I need to do a backup. I'm starting with this. #!/bin/bash export MOUNT=/myfilesystem if grep -qs $MOUNT /proc/mounts; then echo "It's mounted." else echo "It's not mounted."; then mount $MOUNT; fi As I said, I'm very basic at scripting. I heard that you can check the status of the mount command by looking at the return codes. RETURN CODES mount has the following return codes (the bits can be ORed): 0 success 1 incorrec (HowTos)