In Linux, Tell me how to list all devices that have the minor number 36 in the system
- User
In Linux, Tell me how to list all devices that have the minor number 36 in the system
- Assistant
In Linux, you can use the
lscommand with the/devdirectory to list devices. However, to filter by minor number specifically, we need to use a combination of shell commands to extract the minor number from the device files and then list only those matching your criteria.Here's one approach using
ls -lto list the device files with their details, andawkto filter by the minor number:ls -l /dev | awk '$5 ~ /,/{split($5, a, ","); if (a[2] == 36) print $0}'Here's what each part of the command does:
ls -l /dev: Lists all the device files in the/devdirectory with detailed information, including the major and minor numbers.awk '$5 ~ /,/{split($5, a, ","); if (a[2] == 36) print $0}': Processes the output from . It breaks down like this: