LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 03-29-2010, 02:05 AM   #1
malickhat
Member
 
Registered: Jun 2009
Posts: 106

Rep: Reputation: 15
Sysdate setting in bash_profile


Hi,
this is my situation,I'm taking backup for some files in that i need to append the sysdate so that i can easily identify which file has to restore at some point,I've tried the following
In my bash_profile(RHEL4)
Code:
SYSDATE=`%d/%m/%Y`
export SYSDATE
i tried after relogin to another terminal ,but when i give the following command
Code:
[malick@home ~]$ echo $SYSDATE

[malick@home ~]$ source ~/.bash_profile
bash: fg: %d/%m/%Y: no such job
I don't know what to do ,once the sysdate is set i can add that element to my script where it takes the back up
 
Old 03-29-2010, 02:15 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Try
Code:
SYSDATE="$( date '+%d/%m/%Y' )"
Notes:
  • %d/%m/%Y is a format string for the date command (except it needs a leading +).
  • ` ` is deprecated in favour of $( ) for reasons given here.
  • Putting it in double quotes ensures that the whole string is assigned to SYSDATE in the unexpected event that output from the date command includes any whitespace.
 
Old 03-29-2010, 02:39 AM   #3
malickhat
Member
 
Registered: Jun 2009
Posts: 106

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by catkin View Post
Try
Code:
SYSDATE="$( date '+%d/%m/%Y' )"
Notes:
  • %d/%m/%Y is a format string for the date command (except it needs a leading +).
  • ` ` is deprecated in favour of $( ) for reasons given here.
  • Putting it in double quotes ensures that the whole string is assigned to SYSDATE in the unexpected event that output from the date command includes any whitespace.
Hi,
It's working but for half of my requirement ,it's giving me the current date but not with the exact timestamp,like if i logged in a shell the SYSDATE is set as constant value rather than the sync with the clock .so the SYSDATE is always same after i logged in .i need something eactly matches as same as that of date command
 
  


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
bash_profile strycnine Slackware 5 10-22-2006 03:11 PM
.bash_profile dimi Linux - General 1 08-23-2005 09:00 PM
need .bash_profile example true_atlantis Slackware 2 02-07-2004 07:27 PM
.bash_profile sikandar Linux - Software 9 08-31-2003 11:01 AM
.bash_profile Wasim Haider Linux - General 2 09-16-2002 08:12 AM


All times are GMT -5. The time now is 10:47 PM.

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