Problem with loading date into variable
I have the following code:
Code:
#!/bin/bash Instead I get: Code:
Sat Apr 30 13:41:08 EDT 2011 Can anyone tell me the reason for this and give me a work around Thanks Frank |
First of all, you need to remove the space after the =. Secondly, you need to tell Bash to run the command and store the output in the variable. What you're attempting to do is store the text "date" in the variable. What you want to do is the following:
mydate=$(date) You might want to read more about Bash scripting. A good guide can be found here. |
Are you still having problems with this?
|
Sorry for the delay in replying.
Thanks for your Answer. The reference you sent is invaluable. Can you recommend a good 'dead tree' book? I'm marking it solved. Problem is I'm very new to Bash scripting, and I'm trying to convert my old C & PHP programs into Bash. I know what I need to do, but I'm having problems with the mechanics. Frank |
Cool. Unfortunately, I (personally) am unable to recommend a book on Bash as I only really learnt from the guide I provided a link to. Maybe check out some of the books in the bibliography of said guide, or perhaps Learning the bash Shell. There are probably other good books, too.
Out of interest, though, why are you converting C and PHP programs to Bash? |
Quote:
|
|
Another list of tutorials here, with reviews.
|
Dead tree books. These ar every necessary in India (where I come from). Sometimes you commute upto two hours a daya - daily. So leaves little time for using the computer (and most people cant afford laptops).
"The UNIX programming environment" by Kernigan and Pyke. OK |
Quote:
|
Nylex wrote:
Quote:
Thanks to the others for the many online references. Like the commuter from India, I do a lot of traveling where online is not available. Frank |
All times are GMT -5. The time now is 03:07 PM. |