Question: non-recursive find syntax


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Question: non-recursive find syntax
# 1  
Old 02-18-2005
Question: non-recursive find syntax

Hello, I am trying to search a directory for all files matching "G*" without looking in sub-directories "success" and "error". I've searched this forum and found the following syntax, but can't make it work:

find . \( ! -name success -prune -name error -prune \) -type f -name "G*"

Have consulted the man pages for find, experimenting with -depth but no luck. Please let me know what I'm doing wrong.

Thanks,
alexkav
# 2  
Old 02-18-2005
find . \( -name success -prune \) -o \( -name error -prune \) -o -name "G*" -print
# 3  
Old 02-18-2005
Perfect. Thank you!
# 4  
Old 02-21-2005
help again

Hello agian, is it possible to adjust the "find" command to only find files beginning with "G" and followed by numbers?

For example:

good: G102030
bad: GFI_UPLOAD.log

Thanks,
alexkav
# 5  
Old 02-21-2005
Ok, here's using grep:

find . \( -name success -prune \) -o \( -name error -prune \) -o -name "G*" -print) | grep '[0-9]\{6\}'

Thanks,
alexkav
# 6  
Old 03-10-2005
what if i don't know what subdirectories there are?

Quote:
Originally Posted by Perderabo
find . \( -name success -prune \) -o \( -name error -prune \) -o -name "G*" -print
what if there are a lot of subdirectories, or there are subdirectories under subdirectories(like a tree), that is, I shouldn't be specifying what subdirectories not to descend. Isn't there a way to tell find command to search for file only in the specified directory(but do not descend any subdirectory) ?
# 7  
Old 03-10-2005
Look in the faq section for the answer.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help needed - find command for recursive search

Hi All I have a requirement to find the file that are most latest to be modified in each directory. Can somebody help with the command please? E.g of the problem. The directory A is having sub directory which are having subdirectory an so on. I need a command which will find the... (2 Replies)
Discussion started by: sudeep.id
2 Replies

2. UNIX for Dummies Questions & Answers

Recursive Find on file size

Is there a way to use the find command to recursively scan directories for files greater than 1Gb in size and print out the directory path and file name only? Thanks in advance. (6 Replies)
Discussion started by: jimbojames
6 Replies

3. UNIX for Dummies Questions & Answers

Non Recursive Find Command

Hello Unix Gurus, I am using the following find commands: 1) find Input_Path -name '*.' -exec mv -f {} Outputpath \; 2) find Inputpath -name '*.' -exec cp {} Outputpath \; 3) find Somepath -name '*.' Now the problem is my Unix version does not support maxdepth Option for find... (7 Replies)
Discussion started by: pchegoor
7 Replies

4. UNIX for Dummies Questions & Answers

Some advice please on non-recursive find

Hi all, I am currently writing a find-and-remove kind of script that is to be used for Solaris and Linux. Currently am using the find command below that I is in find only current directory (universal) | commandlinefu.com This however gives me the "ksh: /bin/find: arg list too long" error... (6 Replies)
Discussion started by: newbie_01
6 Replies

5. UNIX for Dummies Questions & Answers

Find/Grep Syntax Question

Hi Folks, I am trying to dig through about 100 directories that have 1 or 2 .jpg images stored in each. I want to copy the .jpg to another file in the root directory. Really my ultimate goal is not to have to dig down into each directory to copy the images individually. I thought I could use a... (2 Replies)
Discussion started by: alpinescott
2 Replies

6. UNIX for Advanced & Expert Users

Recursive directory search using ls instead of find

I was working on a shell script and found that the find command took too long, especially when I had to execute it multiple times. After some thought and research I came up with two functions. fileScan() filescan will cd into a directory and perform any operations you would like from within... (8 Replies)
Discussion started by: newreverie
8 Replies

7. UNIX for Advanced & Expert Users

Non recursive find command

Hi, I have question is related to find command. I want to find command should search in current folder only not recursive mode(sub-folders). I found a one way of, find . \( -name success -prune \) -o -name "Rajini*" How ever, my current folder is having lots sub-folders and am not... (7 Replies)
Discussion started by: Nagapandi
7 Replies

8. Shell Programming and Scripting

Recursive find and store

I HAVE A TEXT FILE CONTAINING THE VALUES 1.CPP 2.CPP 3.CPP 4.CPP 5.CPP 6.CPP I WANT TO TAKE EACH .CPP AND USE THE FIND COMMAND TO FIND THE LATEST VERSION OF THE FOLDER IN WHICH IT IS PRESENT. HOW DO I IMPLEMENT IT IN A WHILE LOOP I TRIED SOMETHING LIKE THIS WHILE CAT... (3 Replies)
Discussion started by: ultimatix
3 Replies

9. UNIX for Dummies Questions & Answers

making a recursive find more useful..

Hi everyone, I'm using a recursive find (you know the type, find . -name qwert*) to find a set of files. However, because I'm new to the system and there is not much documentation about these particular files I'm trying to find them using this recursive find. I started off at the location... (3 Replies)
Discussion started by: spanish_tony
3 Replies

10. UNIX for Advanced & Expert Users

Performing a non-recursive find in Unix

I need to perform a non-recursive find in Unix. Sounds simple, but it doesn't actually work. The command ALWAYS searches through the subdirectories. Any ideas? I am on DEC Unix :-( (3 Replies)
Discussion started by: christallott
3 Replies
Login or Register to Ask a Question