Re: a little script

From: Michael Tosch (eedmit_at_NO.eed.SPAM.ericsson.PLS.se)
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:

#!/bin/sh
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


Relevant Pages

  • Re: help with a little script
    ... What kind of script do you want? ... Jasper ... "mabus" wrote: ... > each day a process generates more than 5000 archives in a directory and ...
    (comp.unix.tru64)
  • help with a little script
    ... i need someone to help me with a little sh script i have to run in my ... each day a process generates more than 5000 archives in a directory and ... make a tar file with them; if the archives have a name like this: ... Mabus ...
    (comp.unix.unixware.misc)
  • help with a little script
    ... each day a process generates more than 5000 archives in a directory and ... make a tar file with them; if the archives have a name like this: ... how do i create a script that moves them and make a tar ...
    (comp.unix.tru64)
  • a little script
    ... i need someone to help me with a little sh script i have to run in my ... each day a process generates more than 5000 archives in a directory and ... make a tar file with them; if the archives have a name like this: ...
    (comp.unix.shell)
  • help with a little script
    ... i need someone to help me with a little sh script i have to run in my ... each day a process generates more than 5000 archives in a directory and ... make a tar file with them; if the archives have a name like this: ...
    (comp.unix.admin)