Hi there, You simply need to use quotes, much like you did on the command line. Thus
EDATE=`date +'%s' -d $TDATE` becomes EDATE=`date +'%s' -d "$TDATE"` ... and so on for your other references to $TDATE. Regards, Mark On Friday 22 June 2007 9:07:22 am [EMAIL PROTECTED] wrote: > I would like to report what I think is a bug: why the following linux > "date" command fails to run within a shell script. But, in runs fine on > the command line. I'm running 2.6.21-1.3194.fc7 on a IBM Thinkpad. I've > also tested on an IBM eServer running 2.6.9-55.ELsmp with the same > results. From the shell, it fails with an "extra operand" error. It seems > to misinterpreting the date string and/or formatting string. > > ============ > COMMAND LINE: > remma> date -d "2007-06-22 00:00:00" +'%s' > 1182484800 > > ============ > SHELL SCRIPT: > > #!/bin/sh > # > # ep.sh > # > TDATE="2007-06-01 01:01:01" > echo $TDATE > # > echo "Test#1" > date +%s -d $TDATE > #OR > echo "Test#2" > date -d $TDATE +'%s' > #OR > echo "Test#3" > EDATE=`date -d $TDATE +'%s'` > echo $EDATE > #OR > echo "Test#4" > EDATE=`date +'%s' -d $TDATE` > echo $EDATE > > ~~~~~~~ > > RESULTS: > >ep.sh > > 2007-06-01 01:01:01 > Test#1 > date: extra operand `01:01:01' > Try `date --help' for more information. > Test#2 > date: extra operand `+%s' > Try `date --help' for more information. > Test#3 > date: extra operand `+%s' > Try `date --help' for more information. > > Test#4 > date: extra operand `01:01:01' > Try `date --help' for more information > > _______________________________________________ > Bug-coreutils mailing list > [email protected] > http://lists.gnu.org/mailman/listinfo/bug-coreutils _______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
