:: Re: [DNG] findUUID?
Top Page
Delete this message
Reply to this message
Author: Didier Kryn
Date:  
To: dng
Subject: Re: [DNG] findUUID?
Le 20/12/2025 à 16:31, Peter via Dng a écrit :
> From:    Didier Kryn<kryn@???>
> Date:    Thu, 18 Dec 2025 11:17:07 +0100
>> lsblk -o NAME,UUID
> Then check for a specific device.
> if (lsblk -o UUID | grep "40d81969-8f9d-4964-b214-87bcf273192a" | wc -c)=37 ; then
>    echo device present
> else
>    echo device not present
> fi
>
> The if condition has 3 commands, lsblk, grep and wc.  I'm working on
> something more direct.
>
> 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
>
> The if condition has a syntax error.  Can someone suggest a fix?
>
> From:    Didier Kryn<kryn@???>
> Date:    Thu, 18 Dec 2025 11:57:31 +0100
>> ... RTFM (~:
> I'm aware of manuals and the old RTFM cliche.  The implicit types in
> bash tend to confuse me.  In this instance, I don't know which manual
> might help.


lsblk -alno UUID | grep -c "40d81969-8f9d-4964-b214-87bcf273192a"

is only two commands.

Alternatively:

if lsblk -alno UUID | grep -q "40d81969-8f9d-4964-b214-87bcf273192a";
then printf "yes\n"; else echo printf "No\n"; fi;

--     Didier