Command that works on BASH promp but not from a shell script!
Hi all, anyone feel like enlightening a beginner-shell-scripter?
The section of code I'm stuck on is supposed to take a (unspecifed) number of field titles - for a latex table. This is my code as it stands:
until [ "$field" = "done" ] ; do
fieldnumber=$((fieldnumber + 1))
Here's the bit that really confuses me! When I run the scrip and enter, say, 'example' BASH returns:
field1="example": command not found
obviously if I type that command directly into the BASH prompt it works fine. I thought that a shell script should work in exactly the same way as if you type it straight into the prompt - so why the error?
Any ideas would be appreciated. Cheers, Chris.
Most interpreted languages provide 2 features that control scanning. One is some kind of escape mechanism that says "don't look at the enclosed text for anything special"; this is often a set of quote marks. The other, often eval, says "look at this chunk again".
For your code, I added the eval and an eval of an echo. The echo, being a print statement, is often your best debugging tool:
For this problem, you might want to consider using an array, q.v.
Best wishes ... cheers, makyo
( edit 1: addition )
Thanks Makyo. I hadn't noticed the CODE button - I'll use it in future!
FYI, to increment a variable, this works in bash.
$ AA=1;((AA++));echo $AA
|All times are GMT -5. The time now is 06:49 AM.|