Info über Wechseldatenträger

Aus Si:Wiki von Siegrist SystemLösungen - Informatik und Rezepte
Version vom 29. Dezember 2015, 14:48 Uhr von 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…»)

(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

Get some info about removable devices like Device, Vendor, Model, Serial etc. Useful for creating UDEV-Rules.

Ungültige Sprache.

Die gewünschte Sprache muss wie folgt definiert werden: <source lang="html4strict">...</source>

Unterstützte Sprachen für die Syntaxhervorhebung:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, aimms, algol68, apache, applescript, arm, asm, asp, assemb, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, caddcl, cadlisp, cfdg, cfm, chaiscript, chapel, cil, clojure, cmake, cobol, coffeescript, cpp, csharp, css, cuesheet, d, dart, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, ezt, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, ispfpanel, j, java, java5, javascript, jcl, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nginx, nimrod, nsis, oberon2, objc, objeck, ocaml, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, pic16, pike, pixelbender, pli, plsql, postgresql, postscript, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, qml, racket, rails, rbs, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, rust, sas, scala, scheme, scilab, scl, sdlbasic, smalltalk, smarty, spark, sparql, sql, standardml, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vbscript, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xpp, yaml, z80, zxbasic


#!/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"