![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to find a file named vijay in a directory using find command | amirthraj_12 | UNIX for Dummies Questions & Answers | 6 | 3 Weeks Ago 09:37 AM |
| Can I know find syntax to find given date files | bache_gowda | Shell Programming and Scripting | 3 | 03-26-2008 03:37 AM |
| Little bit weired : Find files in UNIX w/o using find or where command | jatin.jain | Shell Programming and Scripting | 10 | 09-19-2007 03:47 AM |
| Find files older than 20 days & not use find | halo98 | Shell Programming and Scripting | 2 | 05-18-2006 11:19 AM |
| command find returned bash: /usr/bin/find: Argument list too long | yacsil | Shell Programming and Scripting | 1 | 12-15-2003 03:38 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Find help
i am trying to write ideally a one liner that will find all of the folders inside of a volume that don't contain a subfolder starting with the letter e and at the same time do contain a subfolder named 'images' that are not empty.
so far i have this find /Volumes/image/ \! \( -name "e*" -and /images -empty up to this point find /Volumes/image/ \! \( -name "e*" minus the ( of course i am pretty sure that it works to find directories inside of /Volumes/image/ that don't have subdirectories starting with e. Again the desired output is. Volumes/image/*/(no dirs starting with e) and at the same time /Volumes/image/*/images/(anything just not empty). Thats what i am trying to get. Any help will be appreciated. Thanks, Movomito Last edited by Movomito; 04-23-2008 at 07:09 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Quote:
Tested with GNU find: Code:
find /Volumes/image/ -type d \! \( -name "image*" -empty \) \! -name "e*" Last edited by rubin; 04-23-2008 at 08:01 AM. Reason: replaced . with /Volumes/image/ |
|
#3
|
|||
|
|||
|
find /Volumes/image/ -type d \! \( -name "image*" -empty \) \! -name "e*"
this works great. Thank you. However, my output is a list of all of the directories and sub directories. Ideally i would get output that is a list of directories where this is true so rather than this: /Volumes/image/W00EGS1012593 /Volumes/image/W00EGS1012593/images /Volumes/image/W00EGS1012593/images/W00EGS1012593-I00EGS1017114 /Volumes/image/W00EGS1016181 /Volumes/image/W00EGS1016181/images /Volumes/image/W00EGS1016181/images/W00EGS1016181-I1PD10388 /Volumes/image/W00EGS1016199 /Volumes/image/W00EGS1016199/images /Volumes/image/W00EGS1016199/images/W00EGS1016199-I00EGS1016201 i would just get: /Volumes/image/W00EGS1012593 /Volumes/image/W00EGS1016181 /Volumes/image/W00EGS1016199 or even better: /W00EGS1012593 /W00EGS1016181 /W00EGS1016199 thank you. Any help is appreciated |
|
#4
|
||||
|
||||
|
Quote:
Code:
find . -maxdepth 1 -type d \! \( -name "image*" -empty \) \! -name "e*" |
|
#5
|
|||
|
|||
|
the -maxdepth took care of cleaning up my output.
However, now i have noticed that the \! -name "e*" doesn't seem to be working. While it is not outputting directories that start with e it is outputting directories that have subdirectories in them that start with e. For example ./W00EGS1016928 ./W00EGS1016928/images ./W00EGS1016928/images/W00EGS1016928-I01JW231 and ./W00EGS1016928/ebook/ does exist almost there though Thanks |
|
#6
|
||||
|
||||
|
Using maxdepth find will not search in the subdirectories anymore, so back to the initial working code, by modifying it a little, you'd get the output described in your second post:
Quote:
Code:
find . -type d \! \( -name "image*" -empty \) \! -name "e*" | awk -F'/' '{a[$2]++; if ( a[$2]==1 ) print "/"$2}'
|
||||
| Google The UNIX and Linux Forums |