0
cd /home/usr/bin/logs
find . -mtime +1 -print | sed -n -e '/\.\/arc/d' -e 's/.*\//' -e '/*.[0-9]$/p' |  while read i
do
if [-f arc/$i]
then
cat $i >> arc/$i
rm $i
else
mv $i arc
fi
done

The log files are on various formats, such as "valid.app5s.log.1019, app5s.gf3sts.1019, valid.app5s.gf3log.1019, app5s.gf3log.1019, app5s.gf1sts.1019,valid.app5s.gf1log.1019, app5s.sts.1019".

But i couldnt able to do with this. Please, Help me in sorting out the problem..

2 Answers 2

1

Unless I'm missing something you can just use find:

find . -maxdepth 1 -mtime +1 -type f -exec mv {} arc/ \;

That will find any file older than 1 day in the current directory and move it to the "arc" directory.

0

use maxdepth in find command

cd /home/usr/bin/logs
find . -maxdepth 1 -mtime +1 -print |  while read i
do
    if [ -f arc/$i ]
    then
        cat $i >> arc/$i
        rm $i
    else
        mv $i arc
    fi
done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .