0

If I print the USB property of a device I own with the following command, I get the following output

$ udevadm info --no-pager /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3 P: /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3 M: 1-1.3 R: 3 U: usb T: usb_device D: c 189:12 N: bus/usb/001/013 L: 0 // lot of other properties 

I'm interested into the M line. This page says it's Device name in /sys/ (the last component of "P:")

To get it into a script, I run

udevadm info --no-pager "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3" | grep "^M:" | cut -d ':' -f 2 | tr -d ' ' 

Works, but feel hacky.

I'm able to get other properties in a much nicer way with query argument

udevadm info -q property --property=ID_PATH --value /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3 

man page says -q can be among name, symlink, path, property, all. None of them get me what I want.

Is there a way to get it in a similar way to the other properties, without using grep & cut. Something link

udevadm info -q XXX --value /device 
5
  • I've edited to help clarify what I'm looking for Commented Sep 24 at 19:23
  • it would make more sense to ask How to get it in a similar way to the other properties,... Commented Sep 24 at 19:31
  • I'm not sure what you are refering to. The title of question ? Commented Sep 25 at 8:14
  • On a side note: grep "^M:" | cut -d ':' -f 2 | tr -d ' ' can be simplified to grep -Po '^M:\s+\K.*$' or sed -nE 's/^M:\s+(.*)$/\1/p' or awk '/^M:/{print $2}' or perl -nle 'print if s/^M:\s+(.*)$/\1/' ... and IMHO what you did isn't "hacky", but rather normal text processing. Commented Sep 25 at 11:03
  • I guess I'm just surprised this line is not available to query on demand but shown but everything is asked. Commented Sep 25 at 11:25

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.