Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "joining" an array with tabs (default is space)
- X-seq: zsh-users 13565
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Webb Sprague <webb.sprague@xxxxxxxxx>
- Subject: Re: "joining" an array with tabs (default is space)
- Date: Wed, 10 Dec 2008 07:00:30 +0000
- Cc: zsh-users@xxxxxxxxxx
- In-reply-to: <b11ea23c0812091127g19b6b55bqdefd4f30701cddf3@xxxxxxxxxxxxxx>
- Mail-followup-to: Webb Sprague <webb.sprague@xxxxxxxxx>, zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <b11ea23c0812091127g19b6b55bqdefd4f30701cddf3@xxxxxxxxxxxxxx>
On Tue, Dec 09, 2008 at 11:27:38AM -0800, Webb Sprague wrote:
> Hi all,
>
> If I set IFS='\t', it works great with read -A LINE. However I want
> to join the output using '\t' instead of spaces-- is there a simple
> way to do that? I can write a for loop, or maybe recycle print -f
> "\t%s", or maybe use columns in the print, but I was hoping for a
> super graceful (ie typical zsh) approach.
[...]
Try IFS=$'\t'
Then "${var[*]}" will be joined with spaces. It's the same in
every Bourne-like shell but the Bourne shell (and earlier Almquist
shells)
$ IFS=$'\t'
$ set a b
$ echo "$*" | cat -t
a^Ib
$ a=(a b)
$ echo "${a[*]}" | cat -t
a^Ib
Actually, with zsh (and zsh only) $array is the same as
${array[*]}, so:
$ echo "$a" | cat -t
a^Ib
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author