[ale] copy with dynamic rename

Michelangelo Grigni mic at mathcs.emory.edu
Fri Sep 22 12:38:30 EDT 2000


esoteric wrote:
> > gzip < originalname > originalname.$(date '+%m%d%y').gz
> 
> To be Y3K prepared:
> 
> gzip < originalname > originalname.$(date '+%m%d%Y').gz

Should that be Y21C?  Actually, I have a buggy version of
"date" (from AT&T AST tools) so that "date +%y" produces
100; I suppose it would work better here!  But really, why
ruin business for future shell coders?

On gzip: since timestamps and names are involved here, you
might use the "--name" option to store the original
filename and timestamp in each compressed file.  Something
like this:

  mkdir dest
  cp -p * dest
  cd dest
  gzip --name *
  dat=$(date +%Y%m%d)
  for f in *.gz; do mv $f ${f%.gz}.$dat.gz; done

And later:

  gunzip --name *.gz

The files will uncompress to their original names and
timestamps, no matter how thee compressed versions are
named and copied.
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list