Re: Difficulty with a shell function.
Hi,
the script works for me on Debian 12 with a Debian Live 11.5.0 ISO
with on USB stick /dev/sdb. UUID is 2022-09-10-11-55-02-00.
Running it as normal user after minor changes:
destination=2022-09-10-11-55-02-00
destination device is connected.
dev=/dev/sdb1
(I changed the value of $destination and the run of "blkid" to
"/sbin/blkid".)
The output of
lsblk -alno NAME,UUID,LABEL | grep 2022-09-10-11-55-02-00
is
sdb 2022-09-10-11-55-02-00 d-live 11.5.0 xf amd64
sdb1 2022-09-10-11-55-02-00 d-live 11.5.0 xf amd64
With unplugged USB stick i get the expected line
destination device not connected. Aborting.
Is the ISO with UUID 2026-01-19-03-28-45-00 downloadable somewhere ?
(Maybe its partition table causes strange output of lsblk.)
> if ! ( lsblk -alno UUID | grep $destination > /dev/null ); then
Seems to work here.
Out of superstition i would have avoided the "!" by
swapping the then-else-cases and would have put $destination in
"-quotation marks.
I would next put a line into the script before the if-line like
lsblk -alno UUID | grep $destination
to see what lsblk actually replies.
Have a nice day :)
Thomas
Reply to: