On Wed, Jul 01, 2026 at 08:58:08 -0700, [email protected] wrote:
> Hi,
> 
> This shell function is a prototype.
> 
> Test() { \
> workingVolume=40d81969-8f9d-4964-b214-87bcf273192a
> echo "working volume asigned a value; now try blkid."
> if ! blkid -t UUID="$workingVolume" > /dev/null; then
>   printf "workingVolume not found.\n"
> else
>   printf "workingVolume found.\n"
> fi
> echo "Now try to catch the name of the device."
> blkid -t UUID="$workingVolume" | cut -d':'
> }
> 
> The if statement gives the result I expect.
> 
> I miss the syntax to make the last statement work.

Move the last two commands inside the "else ... fi" block, so they aren't
executed when the working volume is not found.

hobbit:~$ blkid
hobbit:~$ sudo blkid
[sudo] password for greg: 
/dev/nvme0n1p3: UUID="afdc7260-5289-4014-bc89-0fa3e843e334" BLOCK_SIZE="4096" 
TYPE="ext4" PARTUUID="599cd65f-67f9-400c-ad22-1c3ee95f5341"
/dev/nvme0n1p1: LABEL_FATBOOT="SYSTEM" LABEL="SYSTEM" UUID="2E5D-D8D4" 
BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" 
PARTUUID="3d23b4eb-5477-417b-9bc9-c2a6d263c2ed"
/dev/nvme0n1p4: LABEL="Windows RE Tools" BLOCK_SIZE="512" 
UUID="D47AB7687AB74650" TYPE="ntfs" PARTLABEL="Basic data partition" 
PARTUUID="bd4e5997-6d42-4f64-9c8b-812355b573bb"
/dev/nvme0n1p2: PARTLABEL="Microsoft reserved partition" 
PARTUUID="9ca2c59a-85fe-4602-9e1e-1937a59834a5"

It looks like what you were trying for was cut -d: -f1

Reply via email to