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:
# @(#) s1 Demonstrate eval.
until [ "$field" = "done" ] ; do
fieldnumber=$((fieldnumber + 1))
eval echo field$fieldnumber="\"$field\""
which, when run, produces:
If you are going to post code here often, please use the CODE tags -- highlight, then click "#
For this problem, you might want to consider using an array, q.v.
Best wishes ... cheers, makyo
( edit 1: addition )