Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi All,
Could someone tell me whats wrong with this script? The script should read a file(the file contains path of files to archive),and then tar the files in the path based on the date.
The filetoarchive.txt looks like this:30 /Gunners/Arsenal
And the script:
#!/bin/ksh
#
# Build list of files to archive
#FileList=$PWD/filelist
> $FileList
while read DAYS ARCH_PATH
do
cd $ARCH_PATH
find . \( -type d ! -name . -prune \) -o -type f -mtime +$DAYS | \
sed "s+^.+$PWD+" >> $FileList
cd -
done < filestoarchive.txt#
# Tar all selected files using builded list
# For some Unix flavour, the -L option is replaced by another option (-I, not sure)
#tar -cvfl kay_`date +%d%m%y%H%M`.tar<$FileList
#
# Delete all tared files only if tar successful
#if [ $? -eq 0 ]
then
while read file
do
rm -f $file
done < $FileList
fi
Any file older than 30days in the file is archived.Could it be better?Or do u have any alternate script?
Thanks
Kayzone

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |