![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| deleting files after the creation of a tar archive | Minguccio75 | UNIX for Advanced & Expert Users | 5 | 02-13-2007 02:26 AM |
| Archive script old files | kayarsenal | Shell Programming and Scripting | 1 | 08-24-2006 10:46 PM |
| Archive files older than 30days | dsravan | Shell Programming and Scripting | 8 | 07-26-2006 01:52 PM |
| script to archive all the log files | tintedwindow | Shell Programming and Scripting | 0 | 06-13-2006 07:51 PM |
| tar archive with .Z files | Kun2112 | UNIX for Dummies Questions & Answers | 3 | 08-05-2005 06:42 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Archive files
Hi All,
I wrote this script: Code:
#!/bin/ksh
while read DAYS ARCH_PATH
do
cd $ARCH_PATH
find . \( -type d ! -name . -prune \) -o -type f -mtime +$DAYS -exec tar -cv
f kay_`date +%d%m%y%H%M`.tar {} \;
cd -
done < filestoarchive.txt
Please advise. |
| Forum Sponsor | ||
|
|
|
||||
|
cd - returns to the previous directory.
I have modified the script a little bit. Code:
#!/bin/ksh FileList=$PWD/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 -cvfL kay_`date +%d%m%y%H%M`.tar $FileList |
|
|||
|
followup
Hi
Still I believe the final command Code:
tar -cvfL kay_`date +%d%m%y%H%M`.tar $FileList For example: I wanted it to archive any files in folder ARSENAL that are older than 40days. In the filestoarchive, I have 40 /path/Arsenal Assuming there are 5files older than 40days, I should have the tar file with the date, and better would be to remove the files. Thanks |
|||
| Google The UNIX and Linux Forums |