Testing For Loop condition

How do I test the return condition in the script if no files are found:

for file in `Find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN}`

do
...
..
done

I want to capture the return code so I can echo the error or condition. Using if [[ $# -eq 0 ]] always returns zero no matter where it's placed.

tia

are you looking for something like:

if [ -e $filename] then
...

this will check if the file exists.

I do the following a check for -s and -r. The find statment in the for loop issues a bad status:

find: bad status-- /home/rnitcher/test/BTIME_ACTUAL_WORK_HRS_wk_[0-9][0-9]_to_[0-9][0-9].csv

I need to capture this return from the find command and exit the program cleanly.

tia

maybe i'm not fully understanding what you're trying to do here... always possible! :stuck_out_tongue:

you want to see what the return code is of a condition?

yes I think so.

...
for file in `find ${LANDING_FILE_DIR}${bTIME_FILENAME_PATTERN1}`

do
....

running the script I get the following find error:

find: bad status-- /.../BTIME_ACTUAL_WORK_HRS_wk_[0-9][0-9]_to_[0-9][0-9].csv

so I'm looking for a way in the script to capture the fact that no file(s) where found and not just have the script abort with the the find: bad status message....

tia