Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
If it’s essential to examine if a quantity is mounted in a Bash script, then you are able to do the next.
First we have to decide the command that may be capable to examine.
This may be completed with the /proc/mounts
path.
if grep -qs '/mnt/foo ' /proc/mounts; then
echo "It is mounted."
else
echo "It isn't mounted."
fi
MNT_DIR=/mnt/foo
df_result=$(timeout 10 df "$MNT_DIR")
[[ $df_result =~ $MNT_DIR ]]
if [ "$BASH_REMATCH" = "$MNT_DIR" ]
then
echo "It is obtainable."
else
echo "It isn't obtainable."
fi
mount
| minimize -f 3 -d ' '
| grep -q /mnt/foo
&& echo "mounted" || echo "not mounted"