Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    [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:
    Each folder has a .csv file representing each day of that month. It looks like this:
    I am trying to find all the csv files EXCEPT those in a folder that has a dot.
    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:
    find /some_path/folder/ \( ! -name "Aug[10-31]*.csv" ! -path "/.*/" -name "*.csv" \) | more
    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.

    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.

  2. #2
    Linux User
    Join Date
    Nov 2009
    I guess the tricky part is filtering out hidden stuff. You may try the following
    find /some_path/folder/ \( ! -name "Aug[10-31]*.csv" -name "*.csv" \) | grep -v "^.*/\..*/.*"
    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.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  3. #3
    here's the 'prune' version:

    $ find . -name '*.txt' -print
    $ find . -path './.*' -prune -o -name '*.txt' -print

  4. $spacer_open
  5. #4
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts