I am just learning shell scripting and already I found out I have the bad habit of thinking that it is similar to php or c.
I learned some basics and now encountered this problem:
On shell it is possible to type:
|
$ date --date="2009-10-10 09:08:34" |
Sat Oct 10 09:08:34 CEST 2009 |
This tells date to output the date in that string in that default format. But now,
I can't pass that string as a variable:
|
$ dateLabel="2009-10-10 09:08:34" |
$ date --date=$dateLabel |
date: the argument `09:08:34' lacks a leading `+'; |
when using an option to specify date(s), any non-option |
argument must be a format string beginning with `+' |
Try `date --help' for more information. |
I thought the problem could be the quotes but I have the same result if I first set the variable to have quotes:
|
$ dateLabel="\"2009-10-10 09:08:34\"" |
$ date --date=$dateLabel |
date: the argument `09:08:34"' lacks a leading `+'; |
when using an option to specify date(s), any non-option |
argument must be a format string beginning with `+' |
Try `date --help' for more information. |
I just don't get it, is it like there is a different encoding for that blank space?
Anyone can help me?