Is this the easiest way on Linux to map from a block device node like /dev/sdb to its corresponding device directory beneath /sys?
(Safe to run as user, Linux only, requires bash & GNU find.)
wwid=$(find /dev/disk/by-id -name 'wwn*' -lname '../../sdb')
wwid=${wwid#"/dev/disk/by-id/wwn-0x"}
printf "WWID of sdb is %s\n" "$wwid"
sysdir=$(dirname "$( \
find /sys/devices -type f -name 'wwid' -exec grep -l "$wwid" {} \; \
)")
printf "That's in %s\n" "$sysdir"
@intrbiz @sil
haha yes I forgot about /sys/block! that's much easier, thanks. 😀