Re: a little script

From: Michael Tosch (
Date: 06/30/05

Date: Thu, 30 Jun 2005 17:33:14 +0200

mabus wrote:
> Hi there,
> i need someone to help me with a little sh script i have to run in my
> machine:
> each day a process generates more than 5000 archives in a directory and
> i need to move all the archives (1 day old) to another directory, and
> make a tar file with them; if the archives have a name like this:
> *YYYYMMDD*, how do i create a script that moves them and make a tar
> with this format *YYYYMMDD*.tar ???
> tks
> Mabus

Assuming you want YYYYMMDD.tar,
and have GNU date:

yd=`date --date yesterday '+%Y%m%d'`
mv *$yd* another/directory
tar cf $yd.tar another/directory/*$yd*

Note that the tar file itself matches the *$yd* pattern, so it should be
at another location.

Michael Tosch @ hp : com