[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Difficulty with a shell function.





On Sun, Jan 25, 2026 at 12:30 AM <peter@easthope.ca> wrote:
# blkid --uuid 2026-01-19-03-28-45-00
/dev/sdc
Meaning that the block device with that UUID is connected to the system.

When this executes,

    destination="2026-01-19-03-28-45-00";
    printf "destination=$destination\n";
    if ! ( lsblk -alno UUID | grep $destination > /dev/null ); then
      printf "destination device not connected.  Aborting.\n"
    else
      printf "destination device is connected.\n"
      dev="$( blkid --uuid $destination )";
      printf "dev=$dev\n";
      # FTH;
    fi;

this is the output.
destination=2026-01-19-03-28-45-00
destination device not connected.  Aborting.

With the device being present, I expect this.
destination=2026-01-19-03-28-45-00
destination device is connected.
dev=/dev/sdc

Does this line have a syntax error?
    if ! ( lsblk -alno UUID | grep $destination > /dev/null ); then

You should run your script through Shellcheck.  It will tell you about the obvious problems, like quoting variables.

Jeff 

Reply to: