> >Hi All,
> >First posting on this forum.
> >I am experiencing a scenario which I try to describe here.
> >Input is a multiline file (actually an xml file), out of which space
> >delimited data fields are extracted using
> >Line 1: for i in `cat file_name`
> >Line 2: do
> >Line 3: var="`echo $i`"
> Why do you need echo there? Why not just:
Its put there to remove possible initial blanks in the field. e.g. if
the field contains " <tag>Data Value</tag>"
I only want the non blank part (i mean trim the initial spaces).
if i do it like you said, echo $i >> temp_out, the spaces will go with
it. or wonn't they ? Correct me if I am wrong.
> In fact, what's $var for anyway? You never use it!
Sorry , but here it was my typo. its actually -
Line 4: echo $var >> temp_out
> >Line 4: echo $i >> temp_out
> >Line 5: done
> >if the data field contains something like "2245123<stringchars", line
> >3 comes up to
> >var="`echo 2245123<stringchars`"
> >which fails... due to possible redirection confusions (that's what I
> It shouldn't. The only processing one on the result of variable expansion
> is word splitting and wildcard expansion. Redirection characters should
> not be processed specially.
> >My question is, if this is the problem, this should happen always, I
> >mean with all kinds of input data files having such data field
> >combinations. But its not. Its occuring very inconsistently.
> Since I don't think it should happen at all, I'm not sure.
> But in any case, the way to avoid all special processing of the variable
> expansion is to put it in quotes:
> echo "$i" >> temp_out
Yeah, You r right its a solution, but I still don't understand why is
this happening. That too inconsistently. Out of about 100 program
executions instances, it failed just once.
thanks and regards