Re: storing todays date into a shell variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mulley, Nikhil wrote:
Yeah Bill, I do not want to reuse the TODAY variable external to the shell script, But what I want to say is When I echo $TODAY  variable , it is not displaying the Data.
myprompt$./storedate
./storedate: +%m/%d/%y: not found
myprompt$

~Nikhil.

-----Original Message-----
From: $Bill Luebkert [mailto:dbecoll@xxxxxxxxxxxx]
Sent: Thursday, December 16, 2004 12:37 PM
To: Mulley, Nikhil
Cc: redhat-list@xxxxxxxxxx
Subject: Re: storing todays date into a shell variable


Mulley, Nikhil wrote:


Hi ,
I wanna have a shell script which puts the today's date into a shell
variable and later use the Shell Variable for other reasons,
I have been using like this..

#!/bin/sh
TODAY=date '+%m/%d/%y'
echo $TODAY
Can any one tell me what could be wrong in this...


Changing the date in your env will only change it for you and any child
processes you create.  Once your shell script exits, the TODAY will
disappear for any new scripts run.


Where you do this: TODAY=date '+%m/%d/%y'

you need to do this:
TODAY=`date '+%m/%d/%y'`

The back ticks will make the application execute to give you the value into TODAY.

I'd go down to the book store and locate either a used or a new book of the Linux Programming Bible for starter, and then maybe look for one specifically on shell programming in itself. I know there are some, but can't remember the names. I've seen them down at Borders.

I found one time using google a shell programming tutorial as well.

Wade

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@xxxxxxxxxx?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

[Index of Archives]     [CentOS]     [Kernel Development]     [PAM]     [Fedora Users]     [Red Hat Development]     [Big List of Linux Books]     [Linux Admin]     [Gimp]     [Asterisk PBX]     [Yosemite News]     [Red Hat Crash Utility]


  Powered by Linux