获取当前连接的 USB 设备列表及其在 BASH 中的开发文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3245015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 19:27:44  来源:igfitidea点击:

Get list of USB devices connected currently and their dev file in BASH

bashunixusb

提问by Mohit Deshpande

What is the bash command for detecting all currently connected USB devices and getting the /dev/tty... file that corresponds to the USB device.

检测所有当前连接的USB设备并获取USB设备对应的/dev/tty...文件的bash命令是什么。

回答by Alberto Zaccagni

Give lsusba try; for the corresponding file I plug in the device and use dmesg, but there sure is a better way...

lsusb一试; 对于我插入设备并使用的相应文件dmesg,但肯定有更好的方法......

回答by vudduu

This can show all USB devices, including devices that you don't have drivers.

这可以显示所有 USB 设备,包括您没有驱动程序的设备。

system_profiler SPUSBDataType

回答by Sergi Mayordomo

Try this:

尝试这个:

lsblk -p -S -o  NAME,TRAN  | grep usb

回答by MattyV

dmesg | grep ttyUSB | grep -v grep | grep -o ttyUSB[0-9]