1846576 Members
2109 Online
110256 Solutions
New Discussion

Re: shell script

 
SOLVED
Go to solution
kholikt
Super Advisor

shell script

I am writing some script to generate list of file from the root file system but I want to exclude /dev directory and i think it is probably not a safe way just to do grep -v for dev as it must exclude some important directory with dev name...

find / -print | grep -v dev
abc
4 REPLIES 4
Con O'Kelly
Honored Contributor
Solution

Re: shell script

Hi

You could try the following:

# find / -type f -xdev -print | grep -v "^/dev/"

This will exclude all files in /dev directory but list all other files in root filesystem only.

Cheers
Con
KapilRaj
Honored Contributor

Re: shell script

I think grep -v "^/dev" is the only way.

If you are looking for only files in root filesystem the following should be sufficient

find / -type f -xdev -print

Regds,

Kaps
Nothing is impossible
KapilRaj
Honored Contributor

Re: shell script

I think grep -v "^/dev" is the only way.

If you are looking for only files in root filesystem the following should be sufficient.

find / -type f -xdev -print

Regds,

Kaps
Nothing is impossible
Francisco J. Soler
Honored Contributor

Re: shell script

Hi kholikt,
another way to do it could be:

find / -path '/dev' -prune -o -print

This exclude /dev and is useful for other directories.

Frank.
Linux?. Yes, of course.