Re: [SLE] Help me please

From: Martin Mielke (martin.mielke_at_thales-is.com)
Date: 04/01/04

  • Next message: Pagan: "[SLE] cdrecord failures"
    Date: Thu, 01 Apr 2004 11:04:18 +0200
    To: suse-linux-e@suse.com
    
    

    Hi,

    handy wrote:

    >Hi I am a novice in Linux.
    >I want to do something in my sles with create a script for my database...my question is :
    >
    >1. How to create a filename with date month year :
    > For example : my filename -> backup30012004
    >
    >

     From 'man date':

        %d day of month (01..31)

        %m month (01..12)

        %Y year (1970...)

    it's quite easy to use and implement:

        a) you can declare (note the backquotes):

              day=`date +"%d"`
              month=`date +"%m"`
              year=`date +"%"`

              full_date=${day}${month}${day}

              or

              full_date=${day}.${month}.${day}

              or

              full_date=${year}${month}${day}

           so, your file would be:

              mv original_filename backup_$fulldate

        b) as in a), you declare $day, $month and $year but you don't
    declare $full_date:

              mv original_filename backup_${day}${month}${day}

    >2. If I want compress with gzip, can I create the filename with date month year directly .
    > For example : gzip -9 backup30012004
    > If it is can be... how to make it
    >
    >

    IIRC, gzip doesn't feature file renaming...
    Taken from 'man gzip':

    ---
    Whenever possible, each file is replaced by one with the extension .gz, 
    while  keeping  the  same  ownership  modes,  access  and modification 
    times.
    ---
    In your case, if you want to have a compressed backupDDMMYYYY file, do 
    the backup on that filename and then compress it. A very general way:
        1. tar -cvf mybackup_${full_date}.tar
        2. gzip -v mybackup_${full_date}.tar
    HTH,
    Martin
    -- 
    Check the headers for your unsubscription address
    For additional commands send e-mail to suse-linux-e-help@suse.com
    Also check the archives at http://lists.suse.com
    Please read the FAQs: suse-linux-e-faq@suse.com
    

  • Next message: Pagan: "[SLE] cdrecord failures"

    Relevant Pages

    • Re: no paths in gzip archives?
      ... archives being files containing multiple other files... ... gzip is used to compress them. ... What does it mean not to store the filename? ...
      (comp.compression)
    • PHP Page performing gzip functions ?
      ... I need to perform a gzip - d command on a specific file. ... Where $filename is replaced with the correct file name? ... Prev by Date: ...
      (alt.php)
    • Re: Can I dont use temp file?
      ... > tar cvf filename.tar BigDir ... > gzip filename.tar ... > mv filename.tar.gz filename ...
      (comp.unix.solaris)
    • Re: stdin/cmd question
      ... Or for clarity and learning, ... xargs -n1 means to do each file one at a time ... gzip -d f2 ...
      (comp.os.linux.misc)