LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 01-29-2010, 02:03 AM   #1
sowraj
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
Unable to print Timestamp


Hi,

I am just trying to print the timestamp. which is not working.

#!/bin/bash

TSTAMP= date '+%d.%m.%y-%H:%M:%S'
echo "${TSTAMP}"


It is not displaying anything.

Can some body pls tell me what is wrong with the above commands.
 
Old 01-29-2010, 03:55 AM   #2
bohemistanbul
LQ Newbie
 
Registered: Jun 2005
Posts: 13

Rep: Reputation: 0
Hi

use that character before and after command : `
and also no whitespace character after = character
the command should be :

#!/bin/bash

TSTAMP=`date '+%d.%m.%y-%H:%M:%S'`
echo ${TSTAMP}
 
Old 01-29-2010, 06:53 AM   #3
sowraj
LQ Newbie
 
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Problem in displaying timestamp

Quote:
Originally Posted by bohemistanbul View Post
Hi

use that character before and after command : `
and also no whitespace character after = character
the command should be :

#!/bin/bash

TSTAMP=`date '+%d.%m.%y-%H:%M:%S'`
echo ${TSTAMP}
I tried it.

If i give ` character before and after the command it is giving an error
date '+%d.%m.%y-%H:%M:%S : not found

date '+%d.%m.%y-%H:%M:%S command is working in the terminal.. why is it not working in the shell script.
 
Old 01-29-2010, 07:02 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Did you add the trailing ' ?

Also, since your post explicitly states the shell is bash, you can use:

Code:
#!/bin/bash
TSTAMP=$(date '+%d.%m.%y-%H:%M:%S')
echo ${TSTAMP}
Evo2.
 
  


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
unable to print kpachopoulos Debian 2 06-23-2006 05:44 PM
Unable to print as a user IBall Linux - General 3 09-07-2004 03:45 AM
unable to print through Samba beowulf405 Linux - Newbie 4 07-03-2004 08:45 PM
Unable to print Bouddha Linux - General 1 09-03-2002 07:34 PM
HP LaserJet 6L + RH 7.2 = unable to print Lanny Linux - Hardware 0 05-06-2002 10:54 AM


All times are GMT -5. The time now is 04:38 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