SunOS: How to exclude directory in find command?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SunOS: How to exclude directory in find command?
# 1  
Old 03-28-2011
SunOS: How to exclude directory in find command?

Hi All,

First my OS version is:
Code:
ksh:0$ uname -a
SunOS 5.9 Generic_122300-48 sun4u sparc SUNW,Sun-Fire-V440

I want to exclude the following DIR(./country111) in my search pattern:
Code:
ksh:0$ find . -name "*.tar"
./country111/COUNTRY_BATCH-801.tar
./country111/COUNTRY_BATCH-802.tar
./country111/COUNTRY_BATCH-803.tar

So I tried:
Code:
ksh:0$ find . -path './country111' -prune -o -name "*.tar" -print

Getting the output like this:
Code:
OUTPUT:
find: bad option -path
find: path-list predicate-list

Please Help.

Thanks,
Saptarshi
# 2  
Old 03-28-2011
Hi saps19,

An option could be:

Code:
find . -name "*.tar" | nawk '!/\.\/country111/'

Regards
This User Gave Thanks to cgkmal For This Post:
# 3  
Old 03-28-2011
Quote:
Originally Posted by cgkmal
Hi saps19,

An option could be:

Code:
find . -name "*.tar" | nawk '!/\.\/country111/'

Regards

It works perfectly...

U Rock!Smilie

Thanks,
Sap.
# 4  
Old 03-28-2011
You're welcome Sap,

This actually shows the output you want, but is not excluding the find command to search "tar" files within "./country111".

This would be no good thing if country111 directory contains a lot of files and subdirectories, in such case, the problem could be
get the output in more time than actually excluding this directory in the search. I hope country111 be a small size directory
Smilie

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Exclude directories in FIND command

Can you please help tweak the below command to exclude all directories with the name "logs" and "tmp" find . -type f \( ! -name "*.tar*" ! -name "*.bkp*" \) -exec /usr/xpg4/bin/grep -i "user_1" /dev/null {} + >result.out bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v... (9 Replies)
Discussion started by: mohtashims
9 Replies

2. Shell Programming and Scripting

How-To Exclude Directory in find command

How can i tweak the below find command to exclude directory/s -> "/tmp/logs" find . -type f \( ! -name "*.log*" ! -name "*.jar*" \) -printNote: -path option/argument does not work with the version of find that i have. bash-3.2$ uname -a SunOS mymac 5.10 Generic_150400-26 sun4v sparc sun4v (7 Replies)
Discussion started by: mohtashims
7 Replies

3. UNIX for Dummies Questions & Answers

cmd find: exclude directory when using option -depth

hello, i want to use "-depth" in command "find" and want to exclude a directory. the find command should work in HP-UX and Linux. i see in the find man page: -prune If -depth is not given, true; do not descend the current directory. If -depth is given, false; no effect. -depth... (3 Replies)
Discussion started by: bora99
3 Replies

4. UNIX for Dummies Questions & Answers

Find command to exclude files with no extension

The below 'ls' command will list down files with extensions and suppress the ones with no extension ls |grep "\\." But this dosen't work when I apply the same logic using 'find' command find . -type f |grep "\\." I need help on how this logic can be implemented using 'find' command (3 Replies)
Discussion started by: meenavin
3 Replies

5. Shell Programming and Scripting

Find command with exclude

I had a Shell script that removes the files that are in a directory older than the specified days. find /test/files -mtime +10 I would like to add another condition to the find command above that is to exclude any file starting with ‘CGU' Thanks (1 Reply)
Discussion started by: db2dbac
1 Replies

6. Shell Programming and Scripting

Exclude a directory in 'find'

Hi, I'm in the process of writing a shell script which will be ran under cron hourly and will check for files of specific age in my ftp folder, then moves those over inside a folder called "old" (which is within the ftp dir). But, I'm unable to figure out how to exclude the "old" folder when... (1 Reply)
Discussion started by: mutex1
1 Replies

7. Shell Programming and Scripting

Help - Find command to exclude sub-directories

Hi Forum. I'm trying to write a script that finds and deletes files that are older than 300 days. The script will read a table that contains the following 3 columns: 1st col: “Y” means sub-directory scan; "N" means no subdirectory scan 2nd col: sub-directory location 3rd col: File prefix... (7 Replies)
Discussion started by: pchang
7 Replies

8. UNIX for Dummies Questions & Answers

find command to exclude directories

Howdy I have this directory structure ... eep eepaptest eepfatest eepgltest eep.old eeppoptest ehf ehfaptest ehfgltest ehp ehpgltest I want to find files in these directories, but I want to exclude eep, ehf & ehp. Cany anyone help with the correct command ?? (1 Reply)
Discussion started by: SmurfGGM
1 Replies

9. Shell Programming and Scripting

How to exclude top level directory with find?

I'm using bash on cygwin/windows. I'm trying to use find and exclude the directory /cygdrive/c/System\ Volume\ Information. When I try to use the command below I get the error "rm: cannot remove `/cygdrive/c/System Volume Information': Is a directory. Can someone tell me what I am doing... (3 Replies)
Discussion started by: siegfried
3 Replies

10. Shell Programming and Scripting

how do i exclude the current directory when using find?

i want to compile a list of files in all sub directories but exclude the current directory. the closest i could get was to search 'only' the current directory, which is the opposite of what i wanted. find . ! -name . -prune (7 Replies)
Discussion started by: mjays
7 Replies
Login or Register to Ask a Question