I have the following statement in script:
find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do
...
done
When there are no files located by the find comand it returns:
"find: bad status-- /home/rnitcher/test/....." to the command line
How do I get control in the script once the find behaves in this fashion? "$?" immediately following the done returns 0.
tia
aigles
April 3, 2008, 3:26am
2
A possible way:
findok=
find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | \
while read file
do
findok=Y
...
done
if [ -z "$findok" ]
then
echo "No file found !"
done
Jean-Pierre.
drl
April 3, 2008, 8:52am
3
Hi.
One could also break the pipeline into pieces, using scratch files to communicate, so that one could test the exit status of each part.
A more complex solution involves using another process for each piece, as explained in ``Answers to Unix'' Column: No. 003 -- quite inventive I think.
Some shells may offer pipefail -- bash and ksh, for example:
... cheers, drl