Find command to exclude a specific path


 
Thread Tools Search this Thread
Operating Systems Linux Red Hat Find command to exclude a specific path
# 1  
Old 08-07-2016
Find command to exclude a specific path

Hi Folks,

I want to run the below command and to exclude the specific path like /var/test/support/... . How to achieve using the below command

Code:
find / -type f \( –perm –4000 –o –perm –2000 \) –print

-Siva
Moderator's Comments:
Mod Comment Please do not use FONT tags inside CODE tags. And, there is usually no reason to use FONT tags at all when posting in this forum.

Last edited by Don Cragun; 08-08-2016 at 12:19 AM.. Reason: Delete FONT tags.
# 2  
Old 08-08-2016
Quote:
Originally Posted by gsiva
Hi Folks,

I want to run the below command and to exclude the specific path like /var/test/support/... . How to achieve using the below command

Code:
find / -type f \( -perm -4000 -o -perm -2000 \) -print

-Siva
Moderator's Comments:
Mod Comment Please do not use FONT tags inside CODE tags. And, there is usually no reason to use FONT tags at all when posting in this forum.
You haven't told us what operating system or version of find you're using. With a standards-conforming find utility, you could use:
Code:
find / -type f \( -perm -4000 -o -perm -2000 \) | grep -v '^/var/test/support/'

If the man page for the find utility on your system includes a -path primary, you could try the following. If you find supports this primary, this version should be faster:
Code:
find / \( -type d -path '/var/test/support' -prune \) -o \( -type f \( -perm -4000 -o -perm -2000 \) \)'

You could add -print to the end of either one of the above find commands and not change the results.
This User Gave Thanks to Don Cragun For This Post:
# 3  
Old 08-08-2016
Hi Don,

I am using Redhat Linux and the command you have given has perfectly worked out for me..

Thanks.. Smilie
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. Shell Programming and Scripting

Solaris FIND: Exclude Specific Paths

Using Sol 10 + KSH. I need to run a find command on the whole system "/" and exclude a bunch of explicit directories and files that may or may not be on each system. I cannot use the -name because i dont want to exclude all dirs named just specific paths. -path/-wholename is not an option... (2 Replies)
Discussion started by: nitrobass24
2 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

SunOS: How to exclude directory in find command?

Hi All, First my OS version is: 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: ksh:0$ find . -name "*.tar" ./country111/COUNTRY_BATCH-801.tar ./country111/COUNTRY_BATCH-802.tar... (3 Replies)
Discussion started by: saps19
3 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

How to Exclude multiple directories from find command?

Hi, Can some one help me how to exclude multiple directories using find command.. I have the directory structure below. /a/a1/b1 /a/c1/c2 /a/d1/d2/d3 I want to exlcude a1,c2and d3 from the above using find,can some one suggest pls.. thanks in advance... Use code tags... (1 Reply)
Discussion started by: jagadish_gaddam
1 Replies

9. Shell Programming and Scripting

Find a path of a specific file

Hi, A variable value is /home/samir/datas/data.txt I want /home/samir/datas. How can I get that. (11 Replies)
Discussion started by: samir_standing
11 Replies

10. 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
Login or Register to Ask a Question