I have a large project for which I'm trying to find directories that don't contain a *_out.csv
file. I have looked at other similar answers and I think I am almost there.
The problem I'm running into is that I only want to look in directories that proceed analysis/
but I also don't want to look in a few specific directories that also proceed analysis.
I have set up a small example problem:
$ tree
.
├── case1
│ ├── analysis
│ │ ├── test1
│ │ │ ├── gold
│ │ │ └── test1_out.csv
│ │ └── test2
│ └── doc
└── case2
├── analysis
│ ├── test3
│ │ └── gold
│ └── test4
│ └── test4_out.csv
└── doc
12 directories, 2 files
I don't want to look in directories titled */doc/*
or */gold/*
. My current command is:
find . -type d -not -name "doc" -not -name "gold" '!' -exec test -e "{}/*_out.csv" ';' -print
Which results in:
.
./case1
./case1/analysis
./case1/analysis/test1
./case1/analysis/test2
./case2
./case2/analysis
./case2/analysis/test3
./case2/analysis/test4
My ideal output would look like
./case1/analysis/test2
./case2/analysis/test3
So as you can see, my current find
command is excluding the doc
and gold
directories, but it's not excluding directories which have a *_out.csv
file and also not excluding directories that don't proceed analysis/
.
analysis/
– dylanjm Jul 23 '19 at 18:27analysis
directories at the same level (e.g. you havecase1/analysis
andnot-a-case/…
) or are there at different levels (e.g. you havecase1/analysis
,case3/sub/analysis
and you also want to look incase3
)? – Gilles 'SO- stop being evil' Jul 23 '19 at 18:27analysis
folders are at the same level, but sometimes the folder structure iscase3/analysis/test1/test1_out.csv
and other times it can becase4/analysis/case4_out.csv
. – dylanjm Jul 23 '19 at 18:30