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

Re: Read command field seperators in Bash



* 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.


Reply to: