Link to home
Start Free TrialLog in
Avatar of kalvillo
kalvillo

asked on

"date" parameter in Batch Files (unix)

Hi.

In DOS, there is a paramether that you can use on your batch file that passes the date of the system (for example, "echo %date%").

Is there a similar parameter on Unix?

Thanks.
Avatar of ozo
ozo
Flag of United States of America image

echo `date`
or just
date
Avatar of kalvillo
kalvillo

ASKER

do you know how to print the ` character on vi?
hi...

Let me explain what i'm trying to do...

I want to make a batch file that builds a tar file with the date on the name, for example "file10-02-09"

`date`returns me the complete date (tue feb 10 14:37:00 pst 2009)

Is there a way to do this?
#!/bin/bash
name=file`date '+%d-%m-%y'`
 echo $name
you could also use
name=file$(date '+%d-%m-%y')
This is the code of my batch file:


#!/bin/bash
name=file$(date'+%d-%m-%y')
tar -cvf /respaldo-mail-huevo/gabriel/name.tar /var/qmail/mailnames/huevocartoon.com/gabriel
gzip /respaldo-mail-huevo/gabriel/name.tar

It creates the following file:

name.tar.gz

It should be

name10-02-09.tar.gz

What am i doing wrong?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
gzip /respaldo-mail-huevo/gabriel/$name.tar