Operating System - HP-UX
1834660 Members
2460 Online
110069 Solutions
New Discussion

A command to find special files according to major and/or minor numbers

 
SOLVED
Go to solution
Jdamian
Respected Contributor

A command to find special files according to major and/or minor numbers

"find" command cannot search for special (device) files whose major be a given value, e.g., LVM files.

As special files has no size, its major/minor numbers are contained in the "size" field of the INODE entry. Thus I thought that "find" command developer made a variation on "-size" option to allow search for major/minor numbers... but not.

Does anyone know a extended-find command ?

3 REPLIES 3
Frederic Sevestre
Honored Contributor
Solution

Re: A command to find special files according to major and/or minor numbers

Hi,

You should try to use find with grep.

for example :
# find /dev -type b(or c) -exec ll {} \; | grep "0x0a0000"

Fr??d??ric

Crime doesn't pay...does that mean that my job is a crime ?
Jeff Schussele
Honored Contributor

Re: A command to find special files according to major and/or minor numbers

Well you can use

find -type c -> for char devices
-type b -> for block devices

Then do

-exec ll {} \;

to get the full listing which will include the major/minor numbers
This could then be piped to grep to get what you want

EX

find /dev -type b -exec ll {} \; | grep 64

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Riou_1
New Member

Re: A command to find special files according to major and/or minor numbers

Frederic is quite right.

I will just give you another way to locate a specified Major number

find /dev/ -exec ll {} \; | awk ' $5 == XX { print $0 }'

where XX is the major

if you look for a minor number just change $5 with $6 ...etc ...

regards
arg!