Unix/Linux Go Back    


UNIX for Beginners Questions & Answers If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

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

UNIX for Beginners Questions & Answers


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 02-28-2018   -   Original Discussion by abdulbadii
abdulbadii's Unix or Linux Image
abdulbadii abdulbadii is offline
Registered User
 
Join Date: Jan 2018
Last Activity: 23 April 2018, 1:31 AM EDT
Posts: 47
Thanks: 3
Thanked 7 Times in 7 Posts
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
Sponsored Links
    #2  
Old Unix and Linux 03-01-2018   -   Original Discussion by abdulbadii
RudiC's Unix or Linux Image
RudiC RudiC is online now Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 23 April 2018, 5:23 AM EDT
Location: Aachen, Germany
Posts: 12,507
Thanks: 401
Thanked 3,878 Times in 3,565 Posts
-o -print will print all files regardless of the tests executed before.
Sponsored Links
    #3  
Old Unix and Linux 4 Weeks Ago   -   Original Discussion by abdulbadii
shajay12's Unix or Linux Image
shajay12 shajay12 is offline
Registered User
 
Join Date: Mar 2018
Last Activity: 30 March 2018, 12:14 AM EDT
Posts: 15
Thanks: 2
Thanked 0 Times in 0 Posts
If -prune doesn't work for you, this will:
Moderator's Comments:
How to find and get a file in an entire directory with an excluded directory specified? 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; 4 Weeks Ago at 08:24 AM..
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find every directory named XYZ under the DVLP directory emc^24sho Shell Programming and Scripting 7 10-16-2013 01:53 PM
Using restorevgfiles to restore entire directory from rootvg problems herot AIX 10 08-28-2012 03:28 PM
tar the entire directory except one directory kalpeer Shell Programming and Scripting 4 09-02-2009 05:22 AM
how to zip the entire directory bbc17484 UNIX for Dummies Questions & Answers 3 06-16-2009 07:25 AM
Script to find a string in a directory/sub-directory gross UNIX for Dummies Questions & Answers 3 11-13-2008 03:45 PM



All times are GMT -4. The time now is 05:25 AM.