LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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, 04:13 AM   #1
checkmate3001
Member
 
Registered: Sep 2007
Location: Folsom, California
Distribution: Debian 4.0 (Etch), Debian 5.0 (Lenny), Ubuntu 8.04
Posts: 301

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, 05:08 AM   #2
GazL
Senior Member
 
Registered: May 2008
Posts: 3,480

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

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

Rep: Reputation: 54
Yeah dude, like brace yourself for the expansion. Cosmic!
 
Old 02-18-2009, 10:27 AM   #4
checkmate3001
Member
 
Registered: Sep 2007
Location: Folsom, California
Distribution: Debian 4.0 (Etch), Debian 5.0 (Lenny), Ubuntu 8.04
Posts: 301

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, 12:10 PM   #5
GazL
Senior Member
 
Registered: May 2008
Posts: 3,480

Rep: Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016Reputation: 1016
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, 01:52 PM   #6
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,043

Rep: Reputation: 375Reputation: 375Reputation: 375Reputation: 375
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 07:32 AM
unix command thread status similar to ps powah Linux - Newbie 1 09-29-2006 11:48 AM
How to grep similar lines in bash? bruno buys Linux - Software 2 12-03-2005 12:56 AM
Exsists in Linux a command similar to ipconfig? zWaR Linux - Newbie 1 03-05-2004 06:27 PM
the diff command or any other similar things murshed Linux - Newbie 4 02-12-2003 11:07 PM


All times are GMT -5. The time now is 08:32 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration