Re: Read command field seperators in Bash
- To: debian-user@lists.debian.org
- Subject: Re: Read command field seperators in Bash
- From: Teemu Likonen <tlikonen@iki.fi>
- Date: Sun, 14 Feb 2010 20:32:19 +0200
- Message-id: <[🔎] 877hqf4qj0.fsf@mithlond.arda>
- In-reply-to: <18989.0704969459$1266164008@news.gmane.org> (John Salmon's message of "Sun, 14 Feb 2010 10:04:41 -0600")
- References: <18989.0704969459$1266164008@news.gmane.org>
* 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: