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

Re: Read command field seperators in Bash



On Sun, 2010-02-14 at 20:32 +0200, Teemu Likonen wrote:
> * 2010-02-14 10:04 (-0600), John Salmon wrote:
> 
> > Is there a way to change the field seperators in Bash's read command
> > (Debian Lenny)?
> 
> The answer has been given but here's an example script which uses
> "read":
> 
>     #!/bin/bash
>     IFS=, read -a numbers < <(echo one,t w o,three)
>     printf '<%s>\n' "${numbers[@]}"
> 
> It will print:
> 
>     <one>
>     <t w o>
>     <three>
> 
> In this case "read" is not necessary. This would do the same:
> 
>     #!/bin/bash
>     IFS=, numbers=( $(echo one,t w o,three) )
>     printf '<%s>\n' "${numbers[@]}"
>     
> 
> -- 
> Feel free to Cc me your replies if you want to make sure I'll notice
> them.
> 
> 

This answers my questions in full. May I say thanks to all who supplied
advice. I'm an old dog learning new tricks and sometimes I need a lot of
help.

I'd also like to say thanks for the info about mawk. I didn't know that
it existed. I had already installed gawk with no appearent conflicts.

    John Salmon
salmonjj@comcast.net


Reply to: