Le 20/12/2025 à 16:31, Peter via Dng a écrit :
> The findmnt manual has this under EXIT STATUS.
> The exit value is 0 if there is something to display, or 1 on any
> error (for example if no filesystem is found based on the user's
> filter specification, or the device path or mountpoint does not
> exist).
>
> if [ findmnt -nrS UUID=$workingVolume ]; then
> echo "$workingVolume is not mounted"
> else
> echo "$workingVolume is mounted"
> fi
There doesn't seem to be a means to silent findmnt other than
redirecting its output to /dev/null.
If what you are looking for is /mounted/ volume, then find the device
name with lsblk -alno NAME,UUID
then use NAME to search /proc/self/mountinfo.
Example: invoke the following script with your uuid as only argument.
#!/bin/sh
MYNAME=$(lsblk -alno NAME,UUID | grep "$1" | cut -d " " -f 1)
if [ "$MYNAME" = "" ] ; then printf "Not found\n"
else
MNTPNT=$(grep "$MYNAME" /proc/self/mountinfo | cut -d " " -f 5);
if [ "$MNTPNT" = "" ]; then printf "Not mounted\n"
else printf '%s\n' "$MNTPNT"
fi;
fi;
This script uses 5 commands: lsblk once, grep twice and cut twice.
It might be possible to invoke only lsblk, and parse the strings and the
file /proc/self/mountinfo in the shell language, but I've no real
expertise in shell. It could also be done in C for example, without
invoking any of these commands.