![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A simple (?) loop | red baron | Shell Programming and Scripting | 2 | 07-10-2008 11:58 AM |
| simple while loop | ali560045 | Shell Programming and Scripting | 10 | 12-26-2007 06:44 AM |
| simple for loop | ali560045 | Shell Programming and Scripting | 3 | 12-16-2007 09:39 PM |
| Simple while loop question | Brokeback | Shell Programming and Scripting | 3 | 07-21-2006 06:04 AM |
| Simple script loop question | mattlock73 | Shell Programming and Scripting | 2 | 05-16-2006 09:55 PM |
|
|
Submit Tools | LinkBack | Thread Tools | 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 12:42 PM. |
| Forum Sponsor | ||
|
|
|
|||
|
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 |