Thread: Bash: Why are these two variables treated differently?
i'm reading value text file environment variable, this;
now, if echo this, looks right. but, there's separate process i'm kicking off (an internal application) tries use variable, , fails.code:export current_q=( $(< "current_q.txt") )
however, if this;
it works.code:tmp_current_q=( $(< "current_q.txt") ) export current_q=$tmp_current_q
have when variable expression parsed? - i.e. in second example, current_q contains 'real' value of variable. in first example, file hasn't been read yet?
confused here.
you can't export array variables. i'm not sure how bash handles export var=( ), it's pointless anyway, don't it. trying do?
reading content of file variable or array, do
code:var=$(<"$filename") # entire content stored 1 long string mapfile -t arr <"$filename" # content stored in array named arr, 1 line per element.
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Bash: Why are these two variables treated differently?
Ubuntu
Comments
Post a Comment