How to find and get a file in an entire directory with an excluded directory specified?

 
Thread Tools Search this Thread
# 1  
Old 03-01-2018
How to find and get a file in an entire directory with an excluded directory specified?

How to get a file 'zlib.h' in an entire directory with an excluded directory specified lives under that starting directory by using find command, as it failed on:

Code:
$  find . -name 'zlib.h' -a -ipath 'CHROME.TMP' -prune -o -print

it'll just list entirely up
# 2  
Old 03-01-2018
-o -print will print all files regardless of the tests executed before.
# 3  
Old 03-22-2018
If -prune doesn't work for you, this will:
Moderator's Comments:
Mod Comment Please use code html tags


Code:
find -name "*.js" -not -path "./directory/*"

---------- Post updated at 05:13 AM ---------- Previous update was at 05:12 AM ----------

Code:
find . -name '*.js' -and -not -path directory

---------- Post updated at 05:14 AM ---------- Previous update was at 05:13 AM ----------

This is the format I used to exclude some paths:

Code:
$ find ./ -type f -name "pattern" ! -path "excluded path" ! -path "excluded path"

I used this to find all files not in ".*" paths:

Code:
$ find ./ -type f -name "*" ! -path "./.*" ! -path "./*/.*"


Last edited by jim mcnamara; 03-22-2018 at 09:24 AM..

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Append two lines of text to php.ini in the entire directory tree.e Larrykh465 UNIX for Dummies Questions & Answers 6 09-05-2015 05:21 PM
Shell scripting-I need a script which should watch a directory for a file with specific directory akashdeepak Shell Programming and Scripting 8 08-26-2014 06:05 PM
Find every directory named XYZ under the DVLP directory emc^24sho Shell Programming and Scripting 7 10-16-2013 02:53 PM
Looping through entire directory and count unique values ritakadm Shell Programming and Scripting 1 07-23-2013 01:31 AM
Using restorevgfiles to restore entire directory from rootvg problems herot AIX 10 08-28-2012 04:28 PM
cannot find file directory Ericyue UNIX for Dummies Questions & Answers 1 04-05-2012 02:12 AM
Grepping file names, comparing them to a directory of files, and moving them into a new directory sHockz Shell Programming and Scripting 1 02-02-2012 02:53 AM
Find file only from a Directory ch33ry Shell Programming and Scripting 12 08-25-2011 03:39 PM
How to Find a String in Each File in a Directory Joule UNIX for Dummies Questions & Answers 1 11-08-2010 07:03 AM
Find file directory magesh_bala Shell Programming and Scripting 8 10-27-2010 05:07 PM
Find file in a directory SimonBASH Shell Programming and Scripting 6 03-23-2010 02:28 PM
tar the entire directory except one directory kalpeer Shell Programming and Scripting 4 09-02-2009 06:22 AM
how to zip the entire directory bbc17484 UNIX for Dummies Questions & Answers 3 06-16-2009 08:25 AM
Script to find a string in a directory/sub-directory gross UNIX for Dummies Questions & Answers 3 11-13-2008 04:45 PM
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 10-25-2008 01:37 PM