Skip to main content
added 131 characters in body
Source Link
Davidbrcz
  • 201
  • 1
  • 6

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 any bettera way ?to get it in a similar way to the other properties, without using grep & cut. Something link

udevadm info -q XXX --value /device 

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 any better way ?

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 
Source Link
Davidbrcz
  • 201
  • 1
  • 6

Read device name in sys with udevadm info

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 any better way ?