Computing.Net > Forums > Unix > Adding date to variable

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Adding date to variable

Reply to Message Icon

Name: nmf
Date: October 19, 2005 at 10:37:35 Pacific
OS: OSX
CPU/Ram: 1.25 g 256 mb
Comment:

I'm attempting to insert the current date into a string of
variable text.
Here is my example and result
begin="this is a test"
datevar='date +%Y-%m-%d'
end="this is the end"
rest=$begin$datevar$end
echo $rest

This returns
this is a testdatevar=date +%Y-%m-%dthis is the end
I just need the current date within the text.

Thank you,
NMF



Sponsored Link
Ads by Google

Response Number 1
Name: Carlitos99
Date: October 19, 2005 at 11:35:40 Pacific
Reply:

for fix your problem
just change '' for ``

your 'date +%Y-%m-%d'
my `date +%Y-%m-%d`

should be work


0

Response Number 2
Name: nmf
Date: October 19, 2005 at 11:50:13 Pacific
Reply:

Thank you so much. I spent two hours experimenting
with different characters. It's always irritating when the
answer is so simple.

Thanks

nmf


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: Adding date to variable

adding date to ftp script...urgent www.computing.net/answers/unix/adding-date-to-ftp-scripturgent/5355.html

Assign Date to a Var www.computing.net/answers/unix/assign-date-to-a-var/3915.html

ksh yyddd (julian date) to yyyymmdd www.computing.net/answers/unix/ksh-yyddd-julian-date-to-yyyymmdd/6471.html