LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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: 3,340

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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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