Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to use output from one command in another?

Featured Replies

Hi

 

I have a question for the real linux gurus around here. I want to reset an usb device in my go script. I compiled usbreset.c and it works quite well. Now I need to know the Bus and Device Number of the usb device to feed into the usbreset script. I have lsusb installed so there is no problem to manually get that information. But I think this can be done automatically?

 

lsusb:

Bus 001 Device 002: ID 8564:1000
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0ccd:0097 TerraTec Electronic GmbH
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

How can I extract the Bus and Device from the first "TerraTec Electronic GmbH" device and feed it into the second one?

/boot/usbreset /dev/bus/usb/002/003

 

 

 

Thanks in advance!

 

edit: I got to this point:

lsusb | awk '{print "/dev/bus/usb/"$2"/"$4}'

(with later exchanging print with /boot/usbreset)

But this gives me every usb device and I still have the colon at the end :-(

Try this:

/boot/usbreset /dev/bus/usb/`lsusb|sed -n "/0ccd:0097/s/^Bus \(0..\) Device \(0..\).*$/\1\/\2/p"`

 

[Note that the (hexadecimal) <Mnfr:Devc> string is unique to the device you are interested in; whereas you might just have more than one "TerraTec ..."-described device. So that is how we select the line to process.]

 

--UhClem

 

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.