Simple date issue

Hi ,

Here is the smaller version of the problem.

Working individually as command

************************>echo $SHELL
/bin/bash
************************>TO_DAY=`date`
************************>echo $TO_DAY
Tue Jul 16 02:28:31 EDT 2013
************************>

Not working when executing from script

************************>./test11.sh
/bin/bash



What could be the possible reason?

Content of test11.sh

echo $SHELL
TO_DAY=`date`
echo $TO_DAY

You need to have the first line of the script as

#! /bin/bash

Are you able to execute your script using

sh test11.sh

Hi

I tried that as well.

Both are not working. Any other command is working properly. Only not working when I am using date.

Please show us your code.

Can you paste the code here again? If there is any space after the assignment "=" then you might have a problem.

You may also try if this works. Instead of assigning date to a variable simply have the script as

echo $SHELL
date

and check if it works.

1 Like

Hi ,

I got the issue. It was real simple. Some one created one empty date file in that folder and because of that it was not working. After deleting that it's working fine.

Thanks anyway for trying to help me out. :b: