Re: [SLE] Help me please
From: Martin Mielke (martin.mielke_at_thales-is.com)
Date: 04/01/04
- Previous message: Koenraad Lelong: "Re: [SLE] Help with firewall (Togan ?)"
- In reply to: handy: "[SLE] Help me please"
- Next in thread: qrn_Hansen?=: "Re: [SLE] Help me please"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message: Koenraad Lelong: "Re: [SLE] Help with firewall (Togan ?)"
- In reply to: handy: "[SLE] Help me please"
- Next in thread: qrn_Hansen?=: "Re: [SLE] Help me please"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|