LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 01: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, 02: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, 05: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, 06:02 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
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



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

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

All times are GMT -5. The time now is 09:32 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
Open Source Consulting | Domain Registration