I need a korn shell script to copy log files of current day to archive folder and rename with current days date stamp.
I would really appreciate your help.
File structure is as follows. Everyday files get overwritten, so I need copy to a archive directory and the renmae with current day.
-rw-r--r-- 1 dmin kin 268609720 Dec 28 04:04 onnector_Arc_01.log
-rw-r--r-- 1 dmin kin 269803781 Dec 29 00:10 dice_Arc_02.log
-rw-r--r-- 1 dmin bin 153013428 Dec 29 08:03 GPS.log
-rw-r--r-- 1 red bin 269804396 Dec 30 08:39 EMC_Arc_01.log
find /logdir -type f -name '*.log' -print | while read FILE ; do
BASENAME=`basename ${FILE} '.log'`
cp ${FILE} /archive/${BASENAME}-`date +%Y-%m-%d`.log
cat > ${FILE} << EOF
EOF # Not indenting this line is intentional
done
Can you please let me know, just to copy today's files only, what should be added?
==============
find /opt/logs/ -type f -name '*.log' -print | while read FILE ; do
BASENAME=`basename ${FILE} '.log'`
cp ${FILE} /tmplog/WBIPRD02/${BASENAME}-`date +%Y-%m-%d`.log
cat > ${FILE} << EOF
EOF # Not indenting this line is intentional
done