read output of process into a variable

2008-01-30 Thread Stefan Palme
Hi, don't know if this is the right newsgroup, but it's the only one I can find with "bash" in its name :-) I want to do something like this: result="" /usr/bin/output_generator | while read line; do extracteddata=`echo "$line" | sed -e 's/X/Y/'` result="$result $extracteddata" done

Re: read output of process into a variable

2008-01-30 Thread Michael Potter
It is not a bug in bash. it is just how it works. the while loop creates a subshell and changes to the variables are not visable outside of the subshell. if you put the while loop first, then it will not create the subshell. do this: result="" while read line; do extracteddata=`echo "$

Re: read output of process into a variable

2008-01-30 Thread Stefan Palme
Thanks for your reply. > It is not a bug in bash. it is just how it works. I know, but did not find a gnu.bash.help newsgroup :$ > do this: > > result="" > while read line; do > extracteddata=`echo "$line" | sed -e 's/X/Y/'` result="$result > $extracteddata" > done < <(/usr/bin

Re: read output of process into a variable

2008-01-30 Thread Bob Proulx
Stefan Palme wrote: > don't know if this is the right newsgroup, but it's the only one > I can find with "bash" in its name :-) That newsgroup is gatewayed to the bug-bash mailing list. > I want to do something like this: > > result="" > /usr/bin/output_generator | while read line; do >

Re: bash 2.05b.0(1)-release on Debian Sarge: [A-Z]* expands as [A-Za-z]* :-(

2008-01-30 Thread Bob Proulx
Alan Mackenzie wrote: > Ah. I've got $LANG set to en_GB. Who did this? How dare they! > OK, I did this myself, somehow, presumably during installation of > Debian Sarge. On Debian: sudo dpkg-reconfigure locales > Why didn't "they" tell me I was messing up my shell? Why do I feel > so stupi

Re: bash 2.05b.0(1)-release on Debian Sarge: [A-Z]* expands as [A-Za-z]* :-(

2008-01-30 Thread Alan Mackenzie
Hi, Bob and Eric, Thanks muchly for the help! On Mon, Jan 28, 2008 at 04:57:22PM -0700, Bob Proulx wrote: > Eric Blake wrote: > > According Alan Mackenzie: > > | % ls [A-Z]* > > | . Sadly, ls ignores my intentions and undiscerningly prints a list of > > | all files whose names begin with a lette

Re: read output of process into a variable

2008-01-30 Thread Stefan Palme
On Wed, 30 Jan 2008 13:44:47 -0700, Bob Proulx wrote: > Stefan Palme wrote: >> don't know if this is the right newsgroup, but it's the only one I can >> find with "bash" in its name :-) > > That newsgroup is gatewayed to the bug-bash mailing list. > >> I want to do something like this: >> >> r