Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Hexadecimalic question ;)



2011-11-10, 18:48(+01), meino.cramer@xxxxxx:
> 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.
>
> Unfortunately I haven't any succes in doing so...
[...]

echo ${hexdig//(#m)?/$arr[1+16#$MATCH]}

also works with:

arr="Thisisanexample!"

-- 
Stephane



Messages sorted by: Reverse Date, Date, Thread, Author