Re: Strange behavior in Korn shell script
- From: Norman Bullen <norm@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Feb 2006 03:22:06 GMT
Dan Mercer wrote:
"Norman Bullen" <norm@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in messageThanks for that.
news:P_sMf.1259$6I.1182@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
: I'm writing a Korn shell script and have encountered a behavior that I
: cannot explain. Perhaps someone else can.
:
: The script contains something like the following:
:
: xxx | sort |
: while read count i rgID
: do
: if (( alloc < N ))
: then
: grep NEXT_LUN_$i_$rgID /tmp/alloc.LUNlist.txt | read id LUN
grep NEXT_LUN_${i}_${rgID} /tmp/alloc.LUNlist.txt | read id LUN
"_" is a legal variable name character which are [_A-Za-z][_A-Za-z0-9]*
You your script is evaluating $i_ and finding it blank.
Dan Mercer
: (( alloc += 1 ))
: fi
: done
:
: (xxx represents a rather complicated loop that prints lines with three
: fields on each. Each of the fields is a decimal number, with the first
: being right-aligned to facilitate the sort. That output has been
: examined and found to be correct. This is sorted on the first field and
: read by the "read" statement in this loop.)
:
: What I cannot explain is the "grep" statements that are generated. I
: expect something like
: grep NEXT_LUN_4_7 /tmp/...
: where "4" and "7" are the value of fields that were read. There should
: be two words, two numbers, and three "_" characters separating them.
:
: What I see when I have trace mode turned on is:
: grep NEXT_LUN_7 /tmp/...
: It's as if one of the numbers and a "_" have been ignored.
:
: I changed the "_" characters to "." characters and I get what I expect:
: grep NEXT.LUN.4.7 /tmp/...
: After an appropriate change to the script component (an awk script) that
: generates /tmp/alloc.LUNlist.txt everything works as I expect.
:
: But why did it not work with the underscore characters? Is "_" somehow
: special to Korn shell? (I can't find any reference to it in my book.)
:
: Norm
:
: -- : --
: To reply, change domain to an adult feline.
:
--
--
To reply, change domain to an adult feline.
.
- References:
- Strange behavior in Korn shell script
- From: Norman Bullen
- Re: Strange behavior in Korn shell script
- From: Dan Mercer
- Strange behavior in Korn shell script
- Prev by Date: Re: Newbie apologies - Spaces and Filenames
- Next by Date: Counting char-string occurrences with sed ?
- Previous by thread: Re: Strange behavior in Korn shell script
- Next by thread: Counting char-string occurrences with sed ?
- Index(es):
Relevant Pages
|
|