scripting help
William Park
opengeometry-FFYn/CNdgSA at public.gmane.org
Fri Aug 10 01:16:52 UTC 2007
On Thu, Aug 02, 2007 at 02:52:21PM -0400, Neil Watson wrote:
> I want to check, in a script, for a file or files that are less than x
> number of days old. If those conditions are met then do something. I
> had something like this in mind:
>
> find ${TOMCAT}build/backup -iname "*war_????????-????" \
> -mtime -$BACKUPAGE || echo "No files found!"
>
> However, I believe that if find encounters any errors, like permission
> denied, the exit value would change and the test would fail.
>
> Can someone suggest a better way?
Check stdout insted of return value, ie.
find ... | while read i; do
echo "found $i"
done
or in 2 steps (preferred),
find ... > /tmp/x
if [ -s /tmp/x ]; then
echo "found something"
fi
--
William Park <opengeometry-FFYn/CNdgSA at public.gmane.org>, Toronto, Canada
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list