@Carona688, thanks for pointing that out. Never having used it before, I assumed that -depth works similarly on Unix. Just found out, otherwise. So how would one go about doing something similar in, say, HP-UX?
Touchy fiddling with the -prune option, perhaps. I have yet to manage a 1:1 equivalent.
You find this sort of thing all the time in UNIX vs Linux utilities. Small little GNU extensions to utilities for pretty obvious features that the UNIX standard doesn't cover, often bafflingly difficult to replace. The -d option to GNU date, which prints whatever date you tell it to, in particular is badly missed...
Hi,
The above solution has worked prefectly as expected....
Incase if i want to proceed with moving the files from Source to Target , only if the log file exits,if not do not do the archive but proceed with the next step in the script.
how can this be achived
Below is the orignal query that i am using:
I have used an "if condtion" to check the status of previous, however it always return 0.
find $LOGDIR -maxdepth 1 \( -name "*.log" -o -name "*.out" \) |
if [ $? != 0 ]; then
echo "No Log Files to Achrive"
else
while IFS="." read FILE
do
BASE=`basename "$FILE"`
echo "$BASE" >/tmp/$$
IFS="." read BASE EXT < /tmp/$$
mv "$FILE" "$LOGARCHIVE/$BASE.$datetimestamp.$EXT"
if [ $? != 0 ]
then
echo "! Error - Error archiving log file !"
fi
done
fi