Info über Wechseldatenträger: Unterschied zwischen den Versionen
Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Sigi (Diskussion | Beiträge) (Die Seite wurde neu angelegt: « Get some info about removable devices like Device, Vendor, Model, Serial etc. Useful for creating UDEV-Rules. <syntaxhighlight lang="sh"> #!/bin/bash REMOVAB…») |
Sigi (Diskussion | Beiträge) |
||
Zeile 3: | Zeile 3: | ||
Useful for creating UDEV-Rules. | Useful for creating UDEV-Rules. | ||
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="bash"> |
#!/bin/bash | #!/bin/bash | ||
Zeile 14: | Zeile 14: | ||
_path=`echo $_device | cut -f5 -d/ --complement` | _path=`echo $_device | cut -f5 -d/ --complement` | ||
_id_devname=`udevadm info --export --query=all --path=$_path | grep DEVNAME= | cut -f2 -d=` | _id_devname=`udevadm info --export --query=all --path=$_path | grep DEVNAME= | cut -f2 -d=` | ||
− | + | _id_model=`udevadm info --export --query=all --path=$_path | grep ID_MODEL= | cut -f2 -d=` | |
− | + | _id_fs_type=`udevadm info --export --query=all --path=$_path | grep ID_FS_TYPE= | cut -f2 -d=` | |
_id_vendor=`udevadm info --export --query=all --path=$_path | grep ID_VENDOR= | cut -f2 -d=` | _id_vendor=`udevadm info --export --query=all --path=$_path | grep ID_VENDOR= | cut -f2 -d=` | ||
_id_serial=`udevadm info --export --query=all --path=$_path | grep ID_SERIAL= | cut -f2 -d=` | _id_serial=`udevadm info --export --query=all --path=$_path | grep ID_SERIAL= | cut -f2 -d=` | ||
− | + | ||
echo -e "\nDevice : $_id_devname\nModel : $_id_model\nVendor : $_id_vendor\nFS-Type: $_id_fs_type\nSerial : $_id_serial\nPath : $_path" | echo -e "\nDevice : $_id_devname\nModel : $_id_model\nVendor : $_id_vendor\nFS-Type: $_id_fs_type\nSerial : $_id_serial\nPath : $_path" | ||
− | + | ||
REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk" | REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk" | ||
((i++)) | ((i++)) |
Version vom 29. Dezember 2015, 14:50 Uhr
Get some info about removable devices like Device, Vendor, Model, Serial etc. Useful for creating UDEV-Rules.
#!/bin/bash REMOVABLE_DRIVES="" i=0 for _device in /sys/block/*/device; do if echo $(readlink -f $_device)|egrep -q "usb"; then _disk=`echo $_device | cut -f4 -d/` _path=`echo $_device | cut -f5 -d/ --complement` _id_devname=`udevadm info --export --query=all --path=$_path | grep DEVNAME= | cut -f2 -d=` _id_model=`udevadm info --export --query=all --path=$_path | grep ID_MODEL= | cut -f2 -d=` _id_fs_type=`udevadm info --export --query=all --path=$_path | grep ID_FS_TYPE= | cut -f2 -d=` _id_vendor=`udevadm info --export --query=all --path=$_path | grep ID_VENDOR= | cut -f2 -d=` _id_serial=`udevadm info --export --query=all --path=$_path | grep ID_SERIAL= | cut -f2 -d=` echo -e "\nDevice : $_id_devname\nModel : $_id_model\nVendor : $_id_vendor\nFS-Type: $_id_fs_type\nSerial : $_id_serial\nPath : $_path" REMOVABLE_DRIVES="$REMOVABLE_DRIVES $_disk" ((i++)) fi done echo -e "\n$i Removable drive(s) found: $REMOVABLE_DRIVES\n"