[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Probably very stupid script/bash question

On Mon, Mar 03, 2008 at 07:48:49PM +0100, Brian wrote:
> Hi,
> I tried using bash to split a string. This works OK:
> echo "$teststring" | { read A B C D E F;  echo "Data received = $E Bytes"; }
> The following does not (the value is empty):
> echo "$teststring" | { read A B C D E F; }
> echo "Data received = $E Bytes"  <--- $E is empty

echo "$teststring" | ( read A B C D E F; )

why do you need the {} or ()

> I assume it has something to do with the read command being executed in  
> a subshell.
> So how can I extract the parts I want into variables to use them later  
> on in the script?
> Thanks in advance
> Cheers Brian
> -- 
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a 
> subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

"I hear the voices, and I read the front page, and I know the speculation, but I?m the decider and I decide what is best. And what?s best is for Don Rumsfeld to remain as secretary of defense."

	- George W. Bush
Washington, DC

Attachment: signature.asc
Description: Digital signature

Reply to: