![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Archive large debug files without cp | firdousamir | Shell Programming and Scripting | 5 | 04-08-2008 10:56 AM |
| Archive files | kayarsenal | Shell Programming and Scripting | 13 | 08-21-2006 12:01 PM |
| Archive files older than 30days | dsravan | Shell Programming and Scripting | 8 | 07-26-2006 05:52 PM |
| script to archive all the log files | tintedwindow | Shell Programming and Scripting | 0 | 06-13-2006 11:51 PM |
| tar archive with .Z files | Kun2112 | UNIX for Dummies Questions & Answers | 3 | 08-05-2005 10:42 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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
Note:dttmfilter and today a c program!The program is working fine,it does exactly what I want it to do,but only when I manually copy the script to the folder I want to archive the files.Now I need to pass readarchive.txt which looks like this: 20 /gunner/chelsea (means archive all files in this folder after 20days) how do I include this in the program? Thanks |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|