This is a discussion on bash scope problem within the Linux Administration forums, part of the Linux Forums category; Hello, Can someone please tell me what I'm doing wrong or have set wrong? From a bash command line, ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hello,
Can someone please tell me what I'm doing wrong or have set wrong? From a bash command line, if I type read -a array then type 1 2 3 I get an array that contains array[0]=1 array[1]=2 array[2]=3 All is good. But, if I type echo "1 2 3" | read -a array I don't have any array defined. It looks like this must be spawning some sort of shell or exec and the array is being defined locally in that context and then is not returned to my current shell. This problem exists even if I try using declare -a array and/or typeset -a array Call me an idiot for not knowing what must be a trivial problem but please let me know what I'm doing wrong! How can I do this and bring the array into the current shell? Thanks, Dave |