help-bash
[Top][All Lists]
Advanced

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

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


From: Peng Yu
Subject: How does {x..y} supposed to work?
Date: Thu, 13 May 2021 11:02:55 -0500

According to the manpage, x and y can be single characters. "the
expression expands to each character lexicographically between x and
y, inclusive".

So my understanding of the behavior of {x..y} should be that `echo
{%..a}` print all the ascii letters between "%" and "a" including "%"
and "a", but it doesn't do so. Do I interpret the manual incorrectly?
Or the bash implementation does not match the manpage completely?

$ echo {%..a}
{%..a}

       A sequence expression takes the form {x..y[..incr]}, where x and y  are
       either  integers or single characters, and incr, an optional increment,
       is an integer.  When integers are supplied, the expression  expands  to
       each  number between x and y, inclusive.  Supplied integers may be pre-
       fixed with 0 to force each term to have the same width.  When either  x
       or  y  begins  with  a  zero, the shell attempts to force all generated
       terms to contain the same number of digits, zero-padding  where  neces-
       sary.   When  characters  are  supplied, the expression expands to each
       character lexicographically between  x  and  y,  inclusive,  using  the
       default  C  locale.   Note  that both x and y must be of the same type.
       When the increment is supplied, it is used as  the  difference  between
       each term.  The default increment is 1 or -1 as appropriate.


-- 
Regards,
Peng



reply via email to

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