What’s the best way to check if a volume is mounted in a Bash script? What I’d really like is a method that I can use like this: if <something is mounted at /mnt/foo> then <Do some
Source: What’s the best way to check if a volume is mounted in a Bash script?
Avoid using
/etc/mtab
because it may be inconsistent.Avoid piping
mount
because it needn’t be that complicated.Simply:
if grep -qs '/mnt/foo' /proc/mounts; then echo "It's mounted." else echo "It's not mounted." fi