help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How does {x..y} supposed to work?


From: Dennis Williamson
Subject: Re: How does {x..y} supposed to work?
Date: Fri, 14 May 2021 22:30:53 -0500

On Fri, May 14, 2021, 6:10 PM Greg Wooledge <greg@wooledge.org> wrote:

> On Fri, May 14, 2021 at 05:59:56PM -0500, Dennis Williamson wrote:
> >  chr ()
> >  {
> >      local c;
> >      for c in "$@";
> >      do
> >          printf "\\$(($c/64*100+$c%64/8*10+$c%8)) ";
> >      done
> >  }
>
> You know you can convert decimal to octal with printf -v var %03o, right?
>

Yes and that requires two printfs. One can use whichever one prefers.

>
> >  $ chr {51..65}; echo
> >  3 4 5 6 7 8 9 : ; < = > ? @ A
>
> Really needs to store the results in a (non-local) array, rather than
> dumping them to stdout.  IMHO.
>

There are times it would be useful in an array but as is it's easy to
include in a command substitution to use it similarly to a brace expansion.

>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]