eer36024@uxa.cso.uiuc.edu (Erik Reuter) (01/28/91)
I need help with the find command. I am trying to use the -prune expression but I cannot get it to work. What I want to do is to search the current directory for all files matching a certain name, say -name abc\* , but I *do not* want find to descend into any subdirectories. find . -type d -prune -o -name abc\* -print does not seem to work, since it prunes *everything*, including the . directory. Any suggestions? -- Erik Reuter, Internet: e-reuter@uiuc.edu UUCP: uunet!uiucuxc!uiuc.edu!e-reuter
raja@bombay.cps.msu.edu (Narayan S. Raja) (01/28/91)
In article <1991Jan28.011044.16609@ux1>, (Erik Reuter) writes:
< What I want to do is to search the current directory for all files matching
< a certain name, say -name abc\* , but I *do not* want find to descend into
< any subdirectories.
<
< find . -type d -prune -o -name abc\* -print
<
< does not seem to work, since it prunes *everything*, including the .
directory.
If you will never search for any property
other than name, plain old
ls -d abc*
should do the job.
Otherwise, the following should work, unless
file abc* is itself a directory:
find . ! -name "." -type d -prune -o -name abc\* -print
If file abc* might possibly be a directory,
find . ! -name "." ! -name abc\* -type d -prune -o -name abc\* -print
will work, but find will recursively search in
directories named abc*.
Narayan Sriranga Raja.
greywolf@unisoft.UUCP (The Grey Wolf) (02/01/91)
In article <1991Jan28.011044.16609@ux1.cso.uiuc.edu> eer36024@uxa.cso.uiuc.edu (Erik Reuter) writes: >What I want to do is to search the current directory for all files matching >a certain name, say -name abc\* , but I *do not* want find to descend into >any subdirectories. > >find . -type d -prune -o -name abc\* -print > >does not seem to work, since it prunes *everything*, including the . directory. > >Any suggestions? find . -type d ! -name . -prune -o -name abc\* -print (excludes "." from the "-prune" restriction) > >-- >Erik Reuter, Internet: e-reuter@uiuc.edu UUCP: uunet!uiucuxc!uiuc.edu!e-reuter -- thought: I ain't so damb dumn! war: Invalid argument ...!{ucbvax,acad,uunet,amdahl,pyramid}!unisoft!greywolf