If you might want to examine if a quantity is mounted in a Bash script, then you are able to do the next.
Methods to Examine Mounted Volumes
First we have to decide the command that may be capable to examine.
This may be achieved with the /proc/mounts
path.
Methods to Examine if a Quantity is Mounted in Bash
if grep -qs '/mnt/foo ' /proc/mounts; then
echo "It is mounted."
else
echo "It is not mounted."
fi
Methods to Examine if a Quantity is Mounted and Out there
MNT_DIR=/mnt/foo
df_result=$(timeout 10 df "$MNT_DIR")
[[ $df_result =~ $MNT_DIR ]]
if [ "$BASH_REMATCH" = "$MNT_DIR" ]
then
echo "It is out there."
else
echo "It is not out there."
fi
One other means of Checking Quantity Mounts
mount
| minimize -f 3 -d ' '
| grep -q /mnt/foo
&& echo "mounted" || echo "not mounted"