LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-20-2010, 01:30 PM   #1
zedmelon
Member
 
Registered: Jun 2004
Location: colorado, USA
Distribution: slack, oBSD
Posts: 119

Rep: Reputation: 24
shell: give a range argument to 'for'


Feel free to just link to another thread where this is (pre)solved; I can't search the forum for the word "for," because it's too short (or maybe the search engine dislikes prepositions).

Is there a way to give the 'for' command a range? Here's what I mean:
Code:
#for i in (1-5); do echo $i; done
 Certainly, meat space user; I understand exactly what you're thinking.
1
2
3
4
5
True, I realize I could use
Code:
COUNT=1 ; while [ $COUNT -lt 6 ]...
...but if I can avoid the extra preparatory step I'd prefer to do so.

Any ideas?
 
Old 02-20-2010, 01:32 PM   #2
zedmelon
Member
 
Registered: Jun 2004
Location: colorado, USA
Distribution: slack, oBSD
Posts: 119

Original Poster
Rep: Reputation: 24
man seq

Short answer:
Code:
man seq
full solution:
Code:
for i in `seq 1 5`; do echo $i; done
Found the solution in this thread about moving a range of file with Bash.

I see some threads marked as [SOLVED]; how can I do that? I don't see it in the control panel.

Last edited by zedmelon; 02-20-2010 at 01:46 PM.
 
Old 02-20-2010, 01:56 PM   #3
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by zedmelon View Post
I see some threads marked as [SOLVED]; how can I do that? I don't see it in the control panel.
Click on thread tools. It's in that menu.
 
1 members found this post helpful.
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
execute script shell with regex as argument eguider Linux - Newbie 2 12-15-2009 07:26 PM
Possible to pass an argument from one shell env to another? ne00 Programming 4 04-15-2009 09:19 PM
a script to give me the last argument !!! rameshvl Linux - General 18 12-29-2008 01:02 PM
Linux makes monitor give frequency out of range error kendall14 Linux - General 2 11-26-2008 08:05 PM
Banshee-"Argument out of range" soldier228 Linux - Software 1 07-10-2007 01:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:58 PM.

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