LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-17-2009, 03:13 AM   #1
checkmate3001
Member
 
Registered: Sep 2007
Location: Folsom, California
Distribution: Ubuntu, Mint, Debian, Suse
Posts: 307

Rep: Reputation: 32
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?
 
Old 02-17-2009, 04:08 AM   #2
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,882

Rep: Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988
'Brace Expansion' is what you're looking for.

Code:
for l in {a..z}
do
  echo $l
done
 
Old 02-17-2009, 04:14 AM   #3
Randux
Senior Member
 
Registered: Feb 2006
Location: Siberia
Distribution: Slackware & Slamd64. What else is there?
Posts: 1,705

Rep: Reputation: 55
Yeah dude, like brace yourself for the expansion. Cosmic!
 
Old 02-18-2009, 09:27 AM   #4
checkmate3001
Member
 
Registered: Sep 2007
Location: Folsom, California
Distribution: Ubuntu, Mint, Debian, Suse
Posts: 307

Original Poster
Rep: Reputation: 32
Thank you so much! I knew it must have been something simple like that. I need a bash scripting book...

Thanks again!
 
Old 02-18-2009, 11:10 AM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,882

Rep: Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988Reputation: 4988
Quote:
Originally Posted by checkmate3001 View Post
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.
 
Old 02-18-2009, 12:52 PM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
http://tldp.org/LDP/abs/html/
 
  


Reply

Tags
bash, command


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with grep (or similar command) tejama Linux - Newbie 12 02-22-2008 06:32 AM
unix command thread status similar to ps powah Linux - Newbie 1 09-29-2006 10:48 AM
How to grep similar lines in bash? bruno buys Linux - Software 2 12-02-2005 11:56 PM
Exsists in Linux a command similar to ipconfig? zWaR Linux - Newbie 1 03-05-2004 05:27 PM
the diff command or any other similar things murshed Linux - Newbie 4 02-12-2003 10:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration