LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-28-2006, 08:33 AM   #1
user52
Member
 
Registered: Nov 2006
Posts: 41

Rep: Reputation: 15
date variable


sir in linux here any date variable they show current system date....


i want to create one shell variable and use exp file..


plz. reply
 
Old 11-28-2006, 08:39 AM   #2
johnpaulodonnell
Member
 
Registered: Jun 2006
Location: Galway
Distribution: Suse 10.1
Posts: 114

Rep: Reputation: 15
/bin/date

although maybe I've misinterpreted your question...
 
Old 11-28-2006, 09:48 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
You can set a variable with the result of running the date command, and then use that as a filename, if that's what you want, like this:
Code:
myfilename="fileame_with_date_$(date +%Y%m%d)_in_the_middle"
echo "This will end up in my file" > "$myfilename"
The +%Y%m%d argument to the date command tells it to return the results in YYYYMMDD format, which is my preference for a well formatted date (it's a very good format because lexical sort order is the same as chronological sort order!).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
thunderbird puts time instead of date under 'date' header wabbalee Linux - Software 4 11-26-2006 05:58 AM
setting a variable variable in a script... this works, but could it be more elegant? pwc101 Programming 3 08-18-2006 12:23 PM
Find variable in template file replace w/date+ and save as jmanjohn61 Linux - General 14 12-13-2004 07:49 AM
Setting environment variable to current date/time nafan Programming 1 08-23-2004 10:04 PM
lastlog date does not match system date? jcmj Linux - Networking 6 10-22-2002 01:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration