-2

Is there a way to get the information of a device in the terminal, providing only his location?

For example I whant to get /dev/sca product information, such as fabricant and model.

Usually i just go to /dev/by-id/ but i am working with some old ubuntu versions.

Solution

inxi --disk-full; hdparm -I /dev/sdb; smartctl -i /dev/sdb; udevadm info --query=all --name=/dev/sdb

4
  • If it is Ubuntu 16.04 or older it is of topic on this site.
    – David DE
    Commented Feb 17, 2022 at 16:53
  • 1
    Try running sudo lshw. It will list some hardware information.
    – Logan
    Commented Feb 17, 2022 at 17:28
  • David it not only for 16.04 for 18.04 and 20.04.
    – Jobesmor
    Commented Feb 17, 2022 at 18:16
  • 1
    So, with location you mean just its path on /dev? Your command is unnecessary complex. Why don't just grep one of these? inxi --disk-full; hdparm -I /dev/sdb; smartctl -i /dev/sdb; udevadm info --query=all --name=/dev/sdb Commented May 9, 2022 at 18:38

1 Answer 1

0

This command solve my problem.

     sudo sed -n -e 1p -e 6p <<< $(tac <<< $(lshw| pcregrep -M '.*((\n|.)*/dev/sdb1)') | pcregrep -M '(/dev/sdb1(\n|.)*?vendor)'|tac)

This scrip uses pcregrep to find in "lshw"´s output the line with "/dev/sda1" and keeps all the lines previous to the match, then invert the lines order with tac, filters again with pcregrep from "/dev/sda1" to the first match of "vendor", then with tac it orders it agains like was before and finaly sed extract line 1 and 6 with sed.

The output is this.

         vendor: ADATA  
         serial: AA00000000000489

Had to install pcregrep to use regular expressions in multilines.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .