I have a script that uses 2 loops.
1st loop - searches for a specific file and if that file exists, other tests are performed. To avoid using a lot of CPU on a server, I have decided to use
continue in a loop.
2nd loop - prints out results based on that first loop.
Script more or less looks like this:
for line in `find ./ -type f`; do # first file test if [[ -f /directory/test1 ]]; then present=1 continue fi # second file test if [[ -f /directory/test2 ]]; then present=1 continue fi done if [[ $present = '1' ]]; then echo "exists" else echo "does not exist" fi
So basically, when the first test (first file test or second file test) is valid,
continue will break up the loop and start the new iteration, so it won't reach the bottom of the script.
That will cause the second test to fail and the script will print only results with files that do not exist.
My question is: How to print out all results (exists and does not exist).