How to exclude folders/files in search?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to exclude folders/files in search?
# 1  
Old 06-30-2009
How to exclude folders/files in search?

I have a directory with about 20 folders and many different types of files. I need to search for files and gzip in all the directories except for 1 directory.

How do you exclude a directory?
# 2  
Old 06-30-2009
I am not sure whether there is any option in 'find' command to get this done. A work around would be to pipe the output of find with 'grep -v'.

find . -name "*.gzip" | xargs grep -v TEST (where TEST is the directory to be excluded)
# 3  
Old 06-30-2009
try the -prune option as in

Code:
 
find . -wholename './src/emacs' -prune -o -print[/FONT][/COLOR]


Last edited by cp_sadag; 06-30-2009 at 05:00 PM.. Reason: just scrapped the title for reply post
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Loop through the folders and search for particular string in files

Hello, Opearting System Environment : HP Unix B.11.31 U I look for script to On specific folders list On specific filelist Search for given string For Example : r48_buildlib.txt contains wpr480.0_20161027 wpr480.0_20161114 wpr481.0_20161208 wpr482.0_20161222... (4 Replies)
Discussion started by: Siva SQL
4 Replies

2. Shell Programming and Scripting

How to copy files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies

3. Shell Programming and Scripting

Exclude certain folders

Hi Experts, Below is my shell script and it will move the files older than 90 days to archive mount. Now my new requirement is , I need to move some of the directory files older than 365 days. How can I achieve this. Simply I have DIR1 DIR2 DIR3 DIR4 I need to exclude DIR 2 and DIR 2... (5 Replies)
Discussion started by: arumugavelvelu
5 Replies

4. Shell Programming and Scripting

Grep for a srting & exclude two folders

Hi, Below is the command to grep for a string under grep -r "redeem" /home/tom Need to make it case insensitive and exclude logs & tmp folders under /home/tom directory in my Search. Need this in Linux. (1 Reply)
Discussion started by: mohtashims
1 Replies

5. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

6. Shell Programming and Scripting

Exclude file from a search script

Hello, I use the following script to delete files from folders. There is an old file I wish to exclude the deletion script. How to exclude a file by name? Current script: ============================= #!/bin/ksh # ---------------------------------------------------- #... (1 Reply)
Discussion started by: pointer
1 Replies

7. Shell Programming and Scripting

Search files from sub folders

A folder contains 30-50 subfolders generated on a daily basis, each subfolder contains more than 10-20 files of .html.gz files format. we have to manually convert the .html.gz file to .html format on a daily basis available in all the sub folders. the procedure we are following is copying... (3 Replies)
Discussion started by: Nareshp
3 Replies

8. UNIX for Dummies Questions & Answers

How do I search while skipping folders?

I have a directory that contains some specific files. I want to find all the files and copy them to a different directory, however the files are in /dir1/dir2/dir3/filedir/archive. In ~/filedir contains about 100 directories that contains an archive directory where the files I need are. How can I... (6 Replies)
Discussion started by: bbbngowc
6 Replies

9. Shell Programming and Scripting

To search for folders alone?

hi Guys, Here i am again,, I need to search for folders alone present in the system,, I tried this command,, find / -name "name of folder" -print But am getting the name of the files also.. i want only the folders name Thanks guys,,, I know i have to repeat the last statement... (3 Replies)
Discussion started by: mac4rfree
3 Replies
Login or Register to Ask a Question