![]() |
|
|
|
|
|||||||
| 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 |
| Archive large debug files without cp | firdousamir | Shell Programming and Scripting | 5 | 04-08-2008 06:56 AM |
| Archive files | kayarsenal | Shell Programming and Scripting | 13 | 08-21-2006 08:01 AM |
| 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 | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Archive script old files
Hi All,
Im trying to write a script to archive files based on the date the files were created. For example, if a group of files were created on 23rd August,I would have 230806.tar. I have a problem,I want the script to read a separately created file(readarchive.txt) to look for the path to archive.It reads the days(after how many days to archive files) and the path.I am not able to figure out how to pass in the readarchive.txt. Heres the script Code:
#!/bin/ksh
BIN=/Gunner/users/Arsenal/tarfiles
age=$1
directory="$2"
[ "$directory" = "" ] && directory=.
cd "$directory" || exit 1
from=`$BIN/today -$age`
ls -rt | grep -v '.tar$' | $BIN/dttmfilter | awk '$1<="'$from'"{ print;};' | \
while read d t f
do
[ -d $f ] && continue
opt=u
[ -w $d.tar ] || opt=c
tar ${opt}f $d.tar $f && touch -r $f $d.tar && rm -f $f
done
20 /gunner/chelsea (means archive all files in this folder after 20days) how do I include this in the program? Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
while read d t f
do
[ -d $f ] && continue
opt=u
[ -w $d.tar ] || opt=c
tar ${opt}f $d.tar $f && touch -r $f $d.tar && rm -f $f
done <readarchive.txt
I guess you want to read from readarchive.txt file using this while loop ?? at the end of done add <filename so that it will read line by line from that file and assigned it to the variable d t f Last edited by blowtorch; 08-24-2006 at 11:05 PM. Reason: add code tags... |
||||
| Google The UNIX and Linux Forums |