for loop syntax trouble


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting for loop syntax trouble
# 8  
Old 04-12-2008
Quote:
Originally Posted by drl
ksh 93s+
See my post below, that syntax is valid in ksh93.

Quote:
Originally Posted by drl
Solaris 10 still has pdksh as the default ksh ... cheers, drl
That is incorrect. Solaris does not and never has had pdksh. The version of ksh in Solars 10 is the official ksh88.
# 9  
Old 04-12-2008
Hi.
Quote:
Originally Posted by reborg
... The version of ksh in Solars 10 is the official ksh88.
Quite right, thanks for the heads-up -- my method for obtaining the version of ksh did not take SunOS adequately into account.

The version 88i does not recognize the extended for statement. Re-running my script s1 in the earlier post under Solaris 10 produces:
Code:
$ ./s1

(Versions displayed with local utility "version")
SunOS 5.10
ksh M-11/16/88i

./s1[12]: syntax error at line 12 : `((' unexpected

So, pdksh 5.2.14 99/07/13.2 and ksh 88i do not recognize the extended for loop syntax, but ksh 93s+ does ... cheers, drl
# 10  
Old 04-13-2008
Sorry for the tone of my post, I didn't mean to flame and obviously I didn't know what I was talking about. Looks like I need to examine the Bash manual more closely.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What does xx mean in this while loop syntax?

I have a shell script which has this while loop line "while read tblName xx; do..." I understand how while loop works but don't know what does this xx stands for? (1 Reply)
Discussion started by: later_troy
1 Replies

2. Shell Programming and Scripting

Considerable trouble with for loop in combination with awk

I have the text file where each line has the format: chr10 101418889 101418904 0.816327 Right now the interval between column 2 and 3 is 15. I only want the two consecutive positions starting at position 1, write it to a file, then move up one position write to file etc. So that: ... (1 Reply)
Discussion started by: jfern
1 Replies

3. UNIX for Dummies Questions & Answers

Trouble understand and using for loop

Good evening all I have what might be a simple problem to solve but I do not know how to solve it myself. I am writing a bash script and my code looks something like this: mp3=`ls | grep \.mp3` for f in $mp3 do echo $f done Basically what I want to do is look through the current... (4 Replies)
Discussion started by: mistsong1
4 Replies

4. UNIX for Dummies Questions & Answers

Trouble displaying parameters passed into a for loop

#!/bin/bash function check_num_args() { if ; then echo "Please provide a file name" else treat_as_file $* fi } function treat_as_file() { numFiles=$# for((i=1;i<=$numFiles;i++));do echo $i ... (3 Replies)
Discussion started by: kikilahooch
3 Replies

5. UNIX for Dummies Questions & Answers

for-loop syntax

%%%%% (3 Replies)
Discussion started by: lucasvs
3 Replies

6. Programming

trouble with loop counting

HI there, I am trying to count manually what this code does but I am stuck and I don't learly see the result. The code works and it compiles and runs but I just don't follow the value of var. #include<stdio.h> #include<stdlib.h> #include<sys/types.h> #include<unistd.h> #include<wait.h>... (2 Replies)
Discussion started by: bluetxxth
2 Replies

7. Shell Programming and Scripting

for loop syntax

hi, I have to use for loop in my script. The below code is providing an output, 1,2,3,4,5..n. But i need to display the values one by one eg: it has to display the first value then exit from the loop and display the second value then exit till n(last value). for i in 1,2,3,4,5..n do ... (2 Replies)
Discussion started by: sreelu
2 Replies

8. Shell Programming and Scripting

Trouble with a file path as awk output in for loop

When I run the following command in the shell it works fine. It prints a city name and then a path for a file. ~$ for i in `awk -F':' '{print $0}' /home/knoppix/Desktop/data/subs | grep -m 1 $ city | sed "s/:/ /"` >do >echo $i >done Now, when I place it in this shell script (sh) it prints... (6 Replies)
Discussion started by: afroCluster
6 Replies

9. Shell Programming and Scripting

Loop Trouble

Can anyone tell me what's wrong with my code here? I'm experiencing weird behavior... I am using 'j' to go down a list filenames saved in a .txt file and prompting the user whether or not she would like to delete each one. This works all well and fine the first run through, but then instead of... (2 Replies)
Discussion started by: RSymphony
2 Replies

10. Shell Programming and Scripting

Start more than one database - trouble with for loop

I have seen this done before - and maybe there is a better way too. I want to be abe to use a for loop (or other better method) to loop through the database instance names that are part of the script - not an external file where a read might be ok. Here is what I have and I know won't work -... (5 Replies)
Discussion started by: dave-mentor
5 Replies
Login or Register to Ask a Question