You are not logged in.
Hello!
I already got an .sh script to show only the mounted filesystems of /dev, so it shows "root" and "boot" filesystem mounted.
and if I connect a device like a usb flash drive it correctly add a new line with the "label + filesystem + space" of the new one mounted.
I wanted to add the model name of these devices, and I found the command:
cat /sys/class/block/sda/device/modelbut this command display only sda device name, if I use sd* it will display all the devices, including the multicard reader I don't need.
I just want to display something like this in my conky:
DEVICE NAME
MOUNTED POINT - FILESYSTEM - USED SPACE / TOTAL SPACE
examples:
TOSHIBA HDD MODEL XXXXX
/ - btrfs - 100 GB / 200 GB
/boot - ext4 - 100 MB / 500 MB
KINGSTON USB FLASH DRIVE MODEL XXXXX
label - vfat - 10GB / 16 GBis it possible??
Last edited by doomguy84 (2018-07-07 10:07:32)
Offline
Sure it's possible - just write it that way:
prev=
findmnt -Dsn -o SOURCE,TARGET,USED,SIZE | sort | while read line; do
cur=${line:5:3}
[ "$cur" != "$prev" ] && echo && cat /sys/class/block/$cur/device/model
echo "$line"
prev=$cur
doneAs is, this puts the device in the first column - this ensures the basename of the device will be at the same character positions for the substring extraction, but if you really wanted it in the other order you could use a regex to get the device name instead. This also lacks your formating characters '-' and '/' but those could be added as desired.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline