I'm using Red Hat - based Linux. I'm using this bash script to find all USB devices and place it to selectList:
read -a devices <<< $(ls -l --time-style=long-iso /dev/disk/by-id)
while [[ ${devices[i]} != "" ]]
do
if [[ ${devices[i]} == usb-* ]] ;
then
if [[ ! ${devices[i+2]} =~ [0-9]$ ]] ;
then
selectList+=${devices[i]}" "
fi
fi
let "i++"
done
For old Linux distributives (old Fedora, CentOS 7) it works OK. But on Fedora 32 this string don't work:
read -a devices <<< $(ls -l --time-style=long-iso /dev/disk/by-id)
because
<<< $(ls -l --time-style=long-iso /dev/disk/by-id)
returns only first string of result ls command.
For example, command
tail -n1 <<< $(ls -l --time-style=long-iso /dev/disk/by-id)
returns on CentOS 7
total 0 lrwxrwxrwx 1 root root 9 2020-07-14 10:23 ata-Optiarc_DVD_RW_AD-5280S -> ../../sr0 lrwxrwxrwx 1 root root 9 2020-07-14 10:23 ata-ST3500514NS_9WJ16TBB -> ../../sda lrwxrwxrwx 1 root root 9 2020-07-14 10:23 ata-ST500DM002-1BD142_Z3T5RLF8 -> ../../sdb lrwxrwxrwx 1 root root 11 2020-07-14 10:23 md-uuid-6a3d48a2:fbd5af07:9ce92935:f469dfc7 -> ../../md127 lrwxrwxrwx 1 root root 11 2020-07-14 10:23 md-uuid-721d0cf4:5fc67883:dbbd7d4c:47ff4941 -> ../../md126 lrwxrwxrwx 1 root root 13 2020-07-14 10:23 md-uuid-721d0cf4:5fc67883:dbbd7d4c:47ff4941-part1 -> ../../md126p1 lrwxrwxrwx 1 root root 13 2020-07-14 10:23 md-uuid-721d0cf4:5fc67883:dbbd7d4c:47ff4941-part2 -> ../../md126p2 lrwxrwxrwx 1 root root 13 2020-07-14 10:23 md-uuid-721d0cf4:5fc67883:dbbd7d4c:47ff4941-part3 -> ../../md126p3 lrwxrwxrwx 1 root root 13 2020-07-14 10:23 md-uuid-721d0cf4:5fc67883:dbbd7d4c:47ff4941-part4 -> ../../md126p4 lrwxrwxrwx 1 root root 13 2020-07-14 10:23 md-uuid-721d0cf4:5fc67883:dbbd7d4c:47ff4941-part5 -> ../../md126p5 lrwxrwxrwx 1 root root 9 2020-07-14 10:23 wwn-0x5000c5002e22dc64 -> ../../sda lrwxrwxrwx 1 root root 9 2020-07-14 10:23 wwn-0x5000c5004e81f353 -> ../../sdb
but on Fedora 32 it returns
lrwxrwxrwx 1 root root 9 2020-07-14 10:23 wwn-0x5000c5004e81f353 -> ../../sdb