Re: [SLUG] Real lamo question about scripts

2003-11-04 Thread Malcolm V
On Mon, 2003-11-03 at 16:54, Jan Schmidt wrote:
 echo mytar-$(date +%d%m%Y).tar.gz
 mytar-03112003.tar.gz
 

Yay for Peter, boo for Jan.

Placing the date in a filename as Year-Month-Day is much neater and it
means a file listing will have the oldest file at the top and the newest
at the bottom (at least for the next 8000 years or so).

Cheers,
Malcolm V.

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-03 Thread James Gray


Kevin Saenz wrote:
Hi all,

I have a bash script where I create a tar.gz file I would 
grab current date and add it to the file name. Could anyone
please advise where I could look so I can develop my script
further?
As others have pointed out date is the command you're looking for, 
man date for details.

I noticed a lot of people suggesting GNU tar command switches 
(specifically -z to compress on the fly).  Be careful if you plan on 
using your script anywhere that DOESNT have the GNU tar version of tar.

To get around this (on Solaris specifically) I use the following syntax 
to create compressed tar files:

tar -cvf - list_of_files | gzip -  myfile-$(date +'%format').tar.gz

Some Solaris systems don't have gzip (pre Solaris 8 IIRC) so you'd need 
to install it manually or use compress instead of gzip.

I know this is a Linux mailing list, but I thought I'd throw this in 
anyway :)

Have Fun,

James

--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-03 Thread Kevin Saenz
Thanks to all who have helped I will mod my script shortly.

-- 
Regards,

Kevin Saenz
 
Spinaweb
I.T consultants
 
Ph: 02 4620 5130
Fax: 02 4625 9243
Mobile: 0418455661
Web: http://www.spinaweb.com.au

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-03 Thread lists
your questioin was nowhere near as dumb as mine,
talking about dumb questions, what do I use to replace 'IF EXIST in a BAT
file's:

IF EXIST something DEL something

?
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-03 Thread Jan Schmidt
quote who=[EMAIL PROTECTED]

 your questioin was nowhere near as dumb as mine,
 talking about dumb questions, what do I use to replace 'IF EXIST in a BAT
 file's:
 
 IF EXIST something DEL something

in sh: 

if [ -x $FILE ]; then
  rm $FILE
fi

Cheers,
Jan.
-- 
Jan Schmidt  [EMAIL PROTECTED]

Homer: No TV and No Beer make Homer something something
Marge: Go Crazy?
Homer: Don't mind if I do! rrrarrgghar!
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-03 Thread Jan Schmidt
quote who=Jan Schmidt

 quote who=[EMAIL PROTECTED]
 
  your questioin was nowhere near as dumb as mine,
  talking about dumb questions, what do I use to replace 'IF EXIST in a BAT
  file's:
  
  IF EXIST something DEL something
 
 in sh: 
 
 if [ -x $FILE ]; then
   rm $FILE
 fi
 

if [ -e $FILE ]; then even... -x is file exists and is executable

see 'man test' for the full set of tests available inside '[]' brackets.

J.
-- 
Jan Schmidt  [EMAIL PROTECTED]

Homer: No TV and No Beer make Homer something something
Marge: Go Crazy?
Homer: Don't mind if I do! rrrarrgghar!
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-03 Thread Peter Hardy
On Tue, 2003-11-04 at 10:28, Jan Schmidt wrote:
 quote who=[EMAIL PROTECTED]
 
  your questioin was nowhere near as dumb as mine,
  talking about dumb questions, what do I use to replace 'IF EXIST in a BAT
  file's:
  
  IF EXIST something DEL something
 
 in sh: 
 
 if [ -x $FILE ]; then
   rm $FILE
 fi

The if bit is easy enough - or check the syntax of how to use if with
help if.  In case you're wondering, the help command is built in (to
bash, at least) and gives help on shell commands that there aren't any
manpages for.

The -x means if $FILE exists and is executable.  I always get stuck
and forget what those conditionals mean.  The bash manpage has a
complete list of them - man bash and search for CONDITIONAL
EXPRESSIONS.

-- 
Pete

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


[SLUG] Real lamo question about scripts

2003-11-02 Thread Kevin Saenz
Hi all,

I have a bash script where I create a tar.gz file I would 
grab current date and add it to the file name. Could anyone
please advise where I could look so I can develop my script
further?

-- 
Regards,

Kevin Saenz
 
Spinaweb
I.T consultants
 
Ph: 02 4620 5130
Fax: 02 4625 9243
Mobile: 0418455661
Web: http://www.spinaweb.com.au

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-02 Thread Brett Fenton
just include `date -I` as part of the file creation routine

ie something like:

tar cfz file.`date -I`.tgz /home

regards
brett
Kevin Saenz wrote:
Hi all,

I have a bash script where I create a tar.gz file I would 
grab current date and add it to the file name. Could anyone
please advise where I could look so I can develop my script
further?

--
Brett Fenton
General Manager
NetRegistry Pty Ltd
___
http://www.netregistry.com.au/

Tel: +61 2 96996099  |  Fax: +61 2 96996088
PO Box 270 Broadway  |  NSW 2007, Australia
Your Total Internet Business Services Provider
Trusted by 10,000s of Oz Businesses Since 1997


This email is from NetRegistry Pty Ltd. The contents of this message are 
commercial and in confidence to the intended addresseee.

The message may contain copyrighted and/or legally priviledged 
information. No person or entity other than the intended recipient may 
read, print or store this message, including any and all attached files.

The intended recipient may not forward this message to any third party 
without express written permission from NetRegistry Pty Ltd.
	

--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-02 Thread Peter Hardy
On Mon, 2003-11-03 at 16:48, Kevin Saenz wrote:
 I have a bash script where I create a tar.gz file I would 
 grab current date and add it to the file name. Could anyone
 please advise where I could look so I can develop my script
 further?

You need the date command.  Check the manpage to find out how to specify
the format.

An example script fragment would look like:
filename=`date +%Y%m%d`

tar zxcf backup-filename.tar.gz /stuff/to/be/backed/up/

Cheers,
-- 
Pete

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug


Re: [SLUG] Real lamo question about scripts

2003-11-02 Thread Peter Hardy
On Mon, 2003-11-03 at 16:59, Peter Hardy wrote:
 tar zxcf backup-filename.tar.gz /stuff/to/be/backed/up/

Er, tar zxvf backup-$filename.tar.gz /stuff/to/be/backed/up/.

I was in a rush trying to get in before Jan did, sorry. :-(

-- 
Pete

-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug