![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A simple (?) loop | red baron | Shell Programming and Scripting | 2 | 07-10-2008 02:58 PM |
| simple while loop | ali560045 | Shell Programming and Scripting | 10 | 12-26-2007 10:44 AM |
| simple for loop | ali560045 | Shell Programming and Scripting | 3 | 12-17-2007 01:39 AM |
| Simple while loop question | Brokeback | Shell Programming and Scripting | 3 | 07-21-2006 09:04 AM |
| Simple script loop question | mattlock73 | Shell Programming and Scripting | 2 | 05-17-2006 12:55 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Hello
I am a beginner of shell scripting and i am having trouble to do a for loop. I want a for loop to do stuff 3 times. i.e. in visual basic i do this for (counter = 0; counter < 3; counter++) on my shell script i have something like this at the moment server=/apps/scripts/server.txt servercount=$(wc -l <$server) #It has 3 lines for i in $servercount do Echo $i done When i run this shell script, it only shows me 3.. but i want it to show 1 2 3 I also tried for (( j = 1 ; j <= 3; j++ )) do echo $j done but i got an error test2.txt: line 4: syntax error near unexpected token `((' test2.txt: line 4: `for ((i = 1;i<= 3;i++))' done Last edited by arex876; 07-23-2008 at 03:42 PM.. |
|
||||
|
Hey guys
My script only shows the result "3" instead of "1" "2" "3" on each line. and i know why it does not work because I used the wrong code at first. I still don't know why the following code is not working for me... i got a syntax error for (( j = 1 ; j <= 3; j++ )) do echo -n $j done |
|
|||||
|
Code:
> for (( j = 1 ; j <= 3 ; j++ )) ; do echo $j; done 1 2 3 Code:
> for (( j = 1 ; j <= 3 ; j++ )) ; do echo -n $j; done ; echo 123 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|