1832211 Members
2859 Online
110040 Solutions
New Discussion

Nonrecursive find.

 
Matt Williamson
Occasional Advisor

Nonrecursive find.

Is there a way to do a nonrecursive find? I'm using find to clean out a tmp directory that contains subdirectories I don't want cleaned out. Is there a way to tell find not to descend the hierarchy and only find files in the base directory given on the command line?
Show me your certification and I'll show you mine!
6 REPLIES 6
Sridhar Bhaskarla
Honored Contributor

Re: Nonrecursive find.

Hi,

You could use 'll /directory |grep -v "^d""

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Jeff Schussele
Honored Contributor

Re: Nonrecursive find.

Hi Matt,

Use the following param:

! -type d

to avoid traversing dirs.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Jan Zalman
Advisor

Re: Nonrecursive find.

Hi,

find ./* ./.* -prune
or
find /fullpath/* /fullpath/.* -prune

Regards
Jan
Time and loyalty cannot be bought.
Jan Zalman
Advisor

Re: Nonrecursive find.


Oops! I typed mistake, it should be
find /tmp/* /tmp/.* -prune ! -type d
Sorry.
Jan
Time and loyalty cannot be bought.
Jean-Louis Phelix
Honored Contributor

Re: Nonrecursive find.

Hi,

I've tested ...

find /tmp/* /tmp/.* -prune ! -type d

Regards
It works for me (© Bill McNAMARA ...)
Matt Williamson
Occasional Advisor

Re: Nonrecursive find.

Hi all. You really came together and figured this one out for me. It works great and has solved one of my sys. admin. problems. Thanks so much for your help.

Matt
Show me your certification and I'll show you mine!