Discussion: zsh array assignment
Afficher un message
Vieux 23/08/2006, 16h36   #2
Stephane Chazelas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: zsh array assignment

On Wed, 23 Aug 2006 17:03:14 +0200, Eric Moors wrote:
> Hi,
>
> I am trying to use the associative arrays in zsh, but I cannot figure out
> how I can assign the output of a command to them. Hopefully someone here
> can provide some assistance (or point me to an alternative)
>
> I'd like to put the output of the jhead command (an image EXIF tag parser)
> into an array. The output of jhead is as follows:
>
> $ jhead img.jpg| grep "^File"
> File name : img.jpg
> File size : 2844547 bytes
> File date : 2006:08:23 16:48:37

[...]

Something like:

typeset -A a
jhead img.jpg | while IFS=": " read -r k v; do a[$k]=$v; done

or:

typeset -A a
IFS=$'\n\n'
a=(
$(jhead img.jpg | sed -n 's/ *: */\
/p')
)


(for example).

--
Stephane
  Réponse avec citation
 
Page generated in 0,05483 seconds with 9 queries