Error with Date cmd


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Error with Date cmd
# 1  
Old 05-19-2008
Error with Date cmd

Hi all,

When i execute the below command its giving an error "date: Bad conversion"

date \"+DATE %m/%d/%Y HEURE %H:%M:%S\"
# 2  
Old 05-19-2008
Off hand, the backslashes in front of the quotation marks look wrong. Does it help if you take those out?
# 3  
Old 05-19-2008
Quote:
Originally Posted by era
Off hand, the backslashes in front of the quotation marks look wrong. Does it help if you take those out?
OR

use single quotes.
# 4  
Old 05-19-2008
Quote:
Originally Posted by agn
OR
use single quotes.
Yes; if you want literal double quotes in the output, then it makes sense:

Code:
vnix$ date +'"DATE %m/%d/%Y HEURE %H:%M:%S"'
"DATE 05/19/2008 HEURE 11:38:45"

Or equivalently, add proper double quotes, and make sure the plus comes first:

Code:
vnix$ date +"\"DATE %m/%d/%Y HEURE %H:%M:%S\""
"DATE 05/19/2008 HEURE 11:39:54"

You might want to read UNIX Shell Quote
# 5  
Old 05-19-2008
I think its better to use single quotes for all situations where you don't require something to be interpolated by the shell.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl open(CMD, "cmd |"); buffering problem..

Hello, There's a third-party application's command that shows the application's status like "tail -f verybusy.log". When use the command, the output comes every 1-sec. but when it goes in a script below the output comes every 8-sec...What is the problem and how can I fix it? open(CMD,... (2 Replies)
Discussion started by: Shawn, Lee
2 Replies

2. Solaris

Error in useradd cmd

Thanks to explain how to resolve this error: useradd -d /export/home/kish -m -s /bin/ksh -c "kkalyan" UX: useradd: ERROR: invalid syntax. usage: useradd | -g group | -G group...] | -d dir | -s shell | -c comment | -m | -f inactive | -e expire | -A... (4 Replies)
Discussion started by: kkalyan
4 Replies

3. Shell Programming and Scripting

cmd || echo "something" - doesn't exit uppon error

Hi guys, I have a shell script where I have the following: for i in ad0 ad1 do gpart create -s gpt $i || echo "Cannot create GPT partition on "$i". Exiting ..." gpart add -s 128 -t freebsd-boot $i || echo "Cannot add freebsd-boot partition on "$i". Exiting ..." gpart add -s 4G -t... (2 Replies)
Discussion started by: da1
2 Replies

4. UNIX for Dummies Questions & Answers

How to Identify date of file backed up used FBACKUP cmd?

Dear UNIX Experts, I'm a newbie. My name is Budi. I need some help from any body in this forum. How do we identify the backed up date of file in the Back up tape ? I did the back up using FBACKUP cmd. I tried to googling it, but unfortunately no aimed solution that I got. :confused: I've... (0 Replies)
Discussion started by: Bhoed
0 Replies

5. Shell Programming and Scripting

Unix cmd prompt how to get old cmd run?

Hi, I am using SunOS I want to serch my previous command from unix prompt (like on AIX we can search by ESC -k) how to get in SunOs urgent help require. (10 Replies)
Discussion started by: RahulJoshi
10 Replies

6. AIX

Yesterday's date without changing anything and in one cmd line ?

I have seen references in the forum about getting yesterday's date but it is either by changing something in the system (date, time zone, ...) or with more then one line of script cmds. How can I get yesterday's date without changing anything in the system and in one single command line ? (4 Replies)
Discussion started by: Browser_ice
4 Replies

7. Shell Programming and Scripting

date with find cmd

Hi for today i have 10 files, in that i need search some values how can i write a find cmd with perticular date thanks SAIC (4 Replies)
Discussion started by: saic
4 Replies

8. Shell Programming and Scripting

want date in format eg:Nov 12 using date cmd

I want date in format eg: using cmd date then it show Dec 05 (2 Replies)
Discussion started by: RahulJoshi
2 Replies

9. Shell Programming and Scripting

date cmd

Hi all, date +%d/%m/%Y This is the command that displays current date(18/09/2008). Now, is there a way that would give me yesterdays date..? or tomorrows date n things like that? (1 Reply)
Discussion started by: vijay_0209
1 Replies

10. UNIX for Dummies Questions & Answers

man <cmd> >> cmd.txt

I've noticed most of my postings here are because of syntax errors. So I want to begin compiling a large txt file that contains all the "man <cmd>" of the commands I most have problems with. I ran a "man nawk >> nawk.txt" but it included a header/footer on each "page". Anyone know how I'd be... (6 Replies)
Discussion started by: yongho
6 Replies
Login or Register to Ask a Question