mountpoint tests whether a given directory is a mount point and returns an appropriate exit status.
mountpoint /mnt/data
mountpoint -q /mnt/data
mountpoint -q /mnt/data echo $?
0 = is mount point, 1 = not mount point
if mountpoint -q /mnt/data; then
echo "Mounted"
else
echo "Not mounted"
fiif mountpoint -q /mnt/data; then
sudo umount /mnt/data
fifor d in /mnt/*; do
mountpoint -q "$d" && echo "$d is mounted"
donefindmnt /mnt/data mountpoint /mnt/data
mountpoint /
mountpoint /mnt/data
Outputs message indicating mount status.
if mountpoint -q /backup; then
rsync -av /data/ /backup/
else
echo "Backup drive not mounted!"
fi