Re: Looping through from A to Z
From: John-Paul Stewart (jpstewart_at_binaryfoundry.ca)
Date: 09/27/05
- Next message: New to Perl: "use of pipes & redirection"
- Previous message: John-Paul Stewart: "Re: Enaled web server on Linux machine, how can I replace default page, need to add 10 files for main page, how to do?"
- In reply to: Paul Colquhoun: "Re: Looping through from A to Z"
- Next in thread: Paul Colquhoun: "Re: Looping through from A to Z"
- Reply: Paul Colquhoun: "Re: Looping through from A to Z"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 27 Sep 2005 11:26:35 -0400
Paul Colquhoun wrote:
> On 26 Sep 2005 06:33:46 -0700, fritz-bayer@web.de <fritz-bayer@web.de> wrote:
> | Hi,
> |
> | does somebody know, which bash construct will allow me to loop through
> | the letters from a to z.
> |
> | for i in [A-Z]*; do echo $i ; done ;
> |
> | Did not work, because it will work on files. I basically nedd a list of
> | characters , which contains all the characters from a to z.
>
>
> for i in $( perl -e 'print join( " ", ( "a" .. "z" ) );' )
I find this suggestion somehow amusing. The $(...) expression is 49
characters to type and requires calling perl (significant execution
overhead). Compare that with:
for i in a b c d e f g h i j k l m n o p q r s t u v w x y z
(Variants on that have already been suggested by both Michael Heiming
and Chris F.A. Johnson.) That's 51 characters to type (26 letters of
the alphabet plus 25 spaces) and doesn't have the overhead of calling
perl.
I suppose the perl solution is more general but I think there's
something to be said for the efficiency of the task-specific solution.
- Next message: New to Perl: "use of pipes & redirection"
- Previous message: John-Paul Stewart: "Re: Enaled web server on Linux machine, how can I replace default page, need to add 10 files for main page, how to do?"
- In reply to: Paul Colquhoun: "Re: Looping through from A to Z"
- Next in thread: Paul Colquhoun: "Re: Looping through from A to Z"
- Reply: Paul Colquhoun: "Re: Looping through from A to Z"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|