Results 1 to 4 of 4
I have spent the last hour searching for a solution to this, but I can't get it to work. Here is what I am trying to do:
I have directories ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-22-2010 #1Just Joined!
- Join Date
- Oct 2010
- Posts
- 9
[SOLVED] Excluding Files From find
I have spent the last hour searching for a solution to this, but I can't get it to work. Here is what I am trying to do:
I have directories for different months in one folder. So for example
Some of the folders have a dot in front of the month as so:Code:../folder/Jan/ ../folder/Aug/ etc.
Each folder has a .csv file representing each day of that month. It looks like this:Code:../folder/.Sep/ ../folder/.Oct/ etc.
I am trying to find all the csv files EXCEPT those in a folder that has a dot.Code:../folder/Jan/Jan01.csv ../folder/Jan/Jan02.csv ../folder/.Oct/Oct01.csv ../folder/.Oct/Oct02.csv
For example I want all the csv files in ../folder/Jan/ but I want none in ../folder/.Oct/.
I also want to exclude all the files in the /Aug/ folder that represent days 10-31.
Here is what I have so far:
This command lists all the .csv files except those in the /Aug/ files. So it just ignores the /Aug/ folder completely but lists every other .csv file.Code:find /some_path/folder/ \( ! -name "Aug[10-31]*.csv" ! -path "/.*/" -name "*.csv" \) | more
Thanks for any help.
PS I also tried using prune, but I probably implemented it incorrectly, because it would not work.Last edited by whocares357; 10-22-2010 at 09:22 PM.
- 10-23-2010 #2Linux User
- Join Date
- Nov 2009
- Location
- France
- Posts
- 292
I guess the tricky part is filtering out hidden stuff. You may try the following
and keep us informed. I haven't fully tried it but it seems to be what you wish on some quickly created files. This is just filtering litteral data through grep.Code:find /some_path/folder/ \( ! -name "Aug[10-31]*.csv" -name "*.csv" \) | grep -v "^.*/\..*/.*"
0 + 1 = 1 != 2 <> 3 != 4 ...
Until the camel can pass though the eye of the needle.
- 10-24-2010 #3Just Joined!
- Join Date
- Feb 2006
- Posts
- 7
here's the 'prune' version:
Code:$ find . -name '*.txt' -print ./.1/file.txt ./.2/file.txt ./.3/file.txt ./1/file.txt ./2/file.txt ./3/file.txt $ find . -path './.*' -prune -o -name '*.txt' -print ./1/file.txt ./2/file.txt ./3/file.txt
- 10-27-2010 #4Just Joined!
- Join Date
- Oct 2010
- Posts
- 9
I ended up just using some of the and/or operators to target the few individual ones I didn't need. Thanks for the help.



