Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Hexadecimalic question ;)
- X-seq: zsh-users 16575
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: meino.cramer@xxxxxx
- Subject: Re: Hexadecimalic question ;)
- Date: Thu, 10 Nov 2011 18:55:50 +0100
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=eZMLB9wA2EgtIesCGrQiCgKgYVpFV+d1ZS83RbR3kes=; b=TIhUs+1EEPFTcKZ6kLECHyiYEl+fZlTGJ/+0IMs8e2NVYRbdkOqLiKItSkrLbKLSk/ 3dKKEjdtNhkm09+K7o6qcC/rjlgHQsuDvj4TloSVolAzvCjH05s6DqE9425WHyebniGW LnlocX0aJuiNoasFgwVgcdJGQPopRpgOuHbb4=
- In-reply-to: <20111110174811.GF24333@solfire>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20111110174811.GF24333@solfire>
On 10 November 2011 18:48, <meino.cramer@xxxxxx> wrote:
> Hi,
>
> I have a string conatining hex digits like this:
>
> hexdig="b05a02d7d1df3e6993eca90fa00241550dc95ec8e22d9b7194e2549cbd2f0ee37ec802d358d7447e0d78568d6f927ca4695173979e0f46573073cc8a785ac181"
>
> and I have an Array like this
>
> arr=( T h i s i s a n e x a m p l e ! ) # Could be any othe contents!
>
> Now I want to step through hexdig digit by digit and use every single
> digit as an index into arr by interpreting each digit as hexadecimal
> digit.
% for i in ${(s::)hexdig}; do echo -n $arr[$(( 16#$i + 1 ))]; done; echo
mTsaTilnlhl!seaxxsepaxT!aTTiihssTlpxsepeeiilxmnhxieisixpmli!TeesnepeTilsselniineTlnesaela!xinpaiaxshnsxnxeT!iasnsTnsppeanesapheh
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author