I need to search and find sub-directories that contain a certain file, however if they contain this certain file + this other file, I do not want them to be listed.
The statement looks something like this:
- Find the directories that contain the file "password.old"
- If the directory contains "password.old" and "webvirtual" don't list them
- If the directory ONLY contains "password.old" and does not contain "webvirtual" then output directory path to > OLD.TXT file
This is what I have thus far, is this totally wrong? It seems to be working correctly, but I'm fairly new to bash scripting and just wanted to make sure I'm not missing something... or maybe there's a better way to handle this?
#!/bin/sh
if FILE=$(find ./ -path OLD/ -prune -o -name "password.old") && FILE=$(find ./ -path OLD/ -prune -o -name "webvirtual*")
then
printf %"s\n" $FILE > Not_Old_Ones.txt
fi
if FILE=$(find ./ -path OLD/ -prune -o -name "password.old") && FILE=$(find ./ -path OLD/ -prune -o ! -name "webvirtual*")
then
printf %"s\n" $FILE > Old_Ones.txt
fi
[
and]
for true/false checks? How would I wrap the find command in the boolean true/false check and apply it to the variableFILE
though so I can output it to a file?