Excluding a directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Excluding a directory
# 1  
Old 05-04-2012
Excluding a directory

i want to search files in public_html of all users and exclude any directories named "uploads" or "albums" (because there are many files in these), just skip them completely

now im doing something like

Code:
find /home/*/public_html -regex ".*\(php\|html\|htm\)$" -path albums -prune -o -type f -print0 | xargs -0 grep -iE 'keyword"

but it's not working to skip over albums directories


the path of albums can be in any level
like


Code:
/home/user/public_html/something/albums

or
Code:
/home/user/public_html/albums

or
Code:
/home/user/public_html/something/somethingelse/albums


thanks in advance for any answers
# 2  
Old 05-05-2012
This is really easy, use:
Code:
find /home/*/public_html -name uploads -prune -o -name albums -prune -o -name "*.php" -print

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Find file with extension and excluding directory

Hi, I have an inquiry on how do I use the find command in Solaris Unix to find some file ends with extension : txt, err in the root directory with modified date of 30days and this find command will also need to exclude b directory and its subdirectory. All the files from the above find criteria... (5 Replies)
Discussion started by: snowfrost88
5 Replies

2. AIX

Excluding directory in my tar Backup

Hello AIX experts. Hope this topic finds you well :) Now, I will take a backup for a directory called medcbs. Inside this directory 1 subdirectory I don't want to include it in the backup. So, how to exclude it? To be more clear, take a look to the following: /bossapp1/medcbs>... (4 Replies)
Discussion started by: Mohannad
4 Replies

3. UNIX for Dummies Questions & Answers

Finding new file, but excluding directory..

hi, I need to find files that have been created less than 3 days ago. However, I need to only search specific directories. I've searched about the net and found some useful commands such as : find . -type d -name 'dir_to_exclude' -prune -o -print -mtime -3 however I cannot get it... (2 Replies)
Discussion started by: horhif
2 Replies

4. Shell Programming and Scripting

excluding a directory with chown, chmod

does anyone know how to exclude a directory with chown or chmod? im trying to do something like this chown $username:$username $directory/* chown $username:$username $directory/.* chown $username:$username $directory and find $directory/* -type f -exec... (1 Reply)
Discussion started by: vanessafan99
1 Replies

5. Shell Programming and Scripting

Excluding directory during deleting

Hi all, I'm trying to work on a script to delete files older then 31 day's in certain directories. Now, that works, but in one directory there are 3 other maps which contains files that can be deleted but one map which contains files that can't be deleted. My current command is: find... (6 Replies)
Discussion started by: JasperG
6 Replies

6. Shell Programming and Scripting

Find all files for a user, excluding a directory

I have been searching, and cannot find an answer for this. I am trying to find all files for a user, lets call him (test001), and I want to exclude a specific directory. Here is the command I run, it finds all files: find / -user test001 I get this result: > find / -user test001 ... (4 Replies)
Discussion started by: steve2x4
4 Replies

7. UNIX for Dummies Questions & Answers

Need help in excluding a particular directory using Find commad

Hi, I have a directory structure as below /home/gad/Merl/a/a1.txt /home/gad/Merl/b/a1.txt /home/gad/Merl/c/a1.txt How can I find the file a1.txt but not from directory 'a' and it(the filw) should loaded 6 days ago.. Can any one pls help,quick reply much appriciated.. Thanks. (1 Reply)
Discussion started by: jagadish_gaddam
1 Replies

8. Shell Programming and Scripting

excluding root directory when searching

I'm writing a script that executes over several subdirectories that looks like this: cd companies #find . -print -type d | find . -type d -print | while read dirname do cd $dirname # run your code at this point if ; then #do somthing else #do something else fi... (1 Reply)
Discussion started by: melearlin
1 Replies

9. UNIX for Dummies Questions & Answers

Find Files in a Directory Excluding Subdirectories

Hi, I have a filename Location.txt in a directory /abc. Similar name file is present in its subdirectory /abc/xyz. I want to find the file which is present only in /abc and not in /abc/xyz. Please any1 of u can provide a quick suggestion. Its very urgent. Thanks, Amol (2 Replies)
Discussion started by: Amol_Dicholkar
2 Replies

10. UNIX for Advanced & Expert Users

find excluding a directory and a file

Hi I have some 5 folders and two files in the current directory. I want to delete all, expect one folder(files in the folder too should not be deleted) and a file in the current directory. Lets say the folder and file that should not be deleted as 'a'(folder name) and 'b'(file name). Can you... (1 Reply)
Discussion started by: ammu
1 Replies
Login or Register to Ask a Question