LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   a little bash help with the 'for' command (or similar) (http://www.linuxquestions.org/questions/linux-general-1/a-little-bash-help-with-the-for-command-or-similar-705292/)

checkmate3001 02-17-2009 04:13 AM

a little bash help with the 'for' command (or similar)
 
Hello my bash friends,

I want to use a for command to iterate through each letter from A to Z.

Is it possible?

I was trying to do something like:
Code:

for l in (A-Z); do.....
Obviously that doesn't work.

Any tips?

GazL 02-17-2009 05:08 AM

'Brace Expansion' is what you're looking for.

Code:

for l in {a..z}
do
  echo $l
done


Randux 02-17-2009 05:14 AM

Yeah dude, like brace yourself for the expansion. Cosmic! :p

checkmate3001 02-18-2009 10:27 AM

Thank you so much! I knew it must have been something simple like that. I need a bash scripting book...

Thanks again!

GazL 02-18-2009 12:10 PM

Quote:

Originally Posted by checkmate3001 (Post 3448324)
Thank you so much! I knew it must have been something simple like that. I need a bash scripting book...

Thanks again!

You're welcome.

If you google for 'bash' and 'tutorial' you'll find quite a lot of information out there. Might be worth a look before laying out some hard cash on a small part of a dead tree. I come from a commercial UNIX background, so I'm more comfortable with Korn shell than bash but taking part in all these LQ threads has been quite educational in itself. :)

i92guboj 02-18-2009 01:52 PM

http://tldp.org/LDP/abs/html/


All times are GMT -5. The time now is 11:57 AM.