[prog] [Bash] script question

Rebecca J. Walter rjp at mail.tele.dk
Sun Sep 29 10:54:17 EST 2002


On Sun, 2002-09-29 at 09:00, Shuying wrote:
> Heya,
> 
> I've written a small script that doesn't do what I want it to do,
> namely rename all files in a particular directory and then zip them all
> up...Can any one tell me what I've done wrong?

What does it do?
I am not as good with bash yet as I want to be, so I am not positive
about all of the syntax. But I have some suggestions.

> 
> #!/bin/sh
> 
> maildir=~shuyingw/mail
> datestamp=`date +%b-%Y`
> 
> for file in $maildir
> do
>   mv $file $file-$datestamp

add a line here like -> echo "Renamed $file to $file-$datestamp"
This will give you some debugging feedback to see if it is working.

>   touch $file
> done
> 
> tar cjvf - $maildir/*$datestamp > /tmp/mail-$datestamp.tar.bz2

are you sure about this format?
I would think it would be tar cjvf /tmp/mail-$datestamp.tar.bz2
$maildir/*$datestamp


I would recommend checking the bits from a shell directly.  Also check
if the renaming has occurred with an ls.  See if you can figure out
where it breaks.





More information about the Programming mailing list