How to Check the type and model of the connected drives | Linux Command | Linux in Pakistan
Shell Script

How to Check the type and model of the connected drives | Linux Command

Command Line

$ printf '/dev/sd%s\n'
{a..z} | xargs -n1 udevadm info -q property -n 2>/dev/null |
egrep -w 'ID_BUS|ID_MODEL|DEVNAME' | sed '3~3a -'

 

steps

  1. printf – Create a template list containing the hard read NKS d the devices that begin with / dev / sd {} to z.

  2. xargs – Reads the device and redirects .

  3. udevadm – Receives the nomenclature sent by xargs, query the query device properties and suppresses the error messages. (if there is)

  4. egrep – Capture the relevant properties only. (ID_BUS, ID_MODEL and DEVNAME)

  5. sed – Axena one (-) every three dash lines separating the information of each device.

Command Output

$ printf ‘/dev/sd%s\n’ {a..z} | xargs -n1  udevadm info -q property -n 2>/dev/null | egrep -w ‘ID_BUS|ID_MODEL|DEVNAME’ | sed ‘3~3a -‘

DEVNAME=/dev/sda
ID_BUS=ata
ID_MODEL=TOSHIBA_MK8034GSX

DEVNAME=/dev/sdb
ID_BUS=usb
ID_MODEL=TF_CARD_Storage

NOTE: If you have a device with a different nomenclature, simply change the initial expression in the ‘/ dev / sd’ in printf command