LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 05-20-2012, 03:24 PM   #1
dth4h
Member
 
Registered: Mar 2009
Posts: 51

Rep: Reputation: 10
for loop not working


This code isn't working:
the num variable will change but for this example it equals 10
Code:
for d in {1..$num};do 
  echo $d
done
It echos
Code:
{1..10}
instead of what I want it to echo witch is
Code:
1
2
3
4
5
6
7
8
9
10

Last edited by dth4h; 05-20-2012 at 03:26 PM.
 
Old 05-20-2012, 03:28 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,490

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
Same problem as in a recent thread. Please, see reply here.
 
1 members found this post helpful.
Old 05-20-2012, 03:29 PM   #3
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 1,956

Rep: Reputation: Disabled
Code:
for (( d=1 ; d<=$num ; d++ )); do
  echo $d
done
 
1 members found this post helpful.
Old 05-20-2012, 03:37 PM   #4
dth4h
Member
 
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 10
Quote:
Originally Posted by Ser Olmy View Post
Code:
for (( d=1 ; d<=$num ; d++ )); do
  echo $d
done
You are awesome! Thanks
 
  


Reply

Tags
bash, variables


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sed not working for loop say_hi_ravi Programming 3 04-05-2012 07:03 AM
how to prove working of RS-232 full modem working PC to PC and LOOP BACK getasif Programming 2 08-20-2011 09:58 AM
[SOLVED] bash loop not working as expected... replica9000 Linux - Software 10 04-24-2011 09:08 AM
Bash for loop not working cryptinitedemon Linux - General 5 04-24-2010 10:44 AM
Loop in this perl script is not working meluser Programming 2 04-01-2003 08:59 PM


All times are GMT -5. The time now is 05:57 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