![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| foreach loop | ROOZ | Shell Programming and Scripting | 3 | 06-05-2008 12:20 PM |
| using foreach loop | sam4now | Shell Programming and Scripting | 6 | 04-26-2008 08:22 AM |
| foreach loop | abch624 | Shell Programming and Scripting | 1 | 03-19-2008 06:34 PM |
| Foreach loop | haze21 | Shell Programming and Scripting | 4 | 11-16-2007 12:11 AM |
| foreach loop question | clipski | UNIX for Dummies Questions & Answers | 7 | 12-22-2005 10:28 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Hi All,
Is there any problem with the below 'foreach' loop? foreach risk_factor ($(cat "$rf_list")) where "rf_list=$SCRIPT/Utility/rflist.txt " I'm wondering, it is throwing below error message: syntax error at line 34: `(' unexpected Any idea/suggestions ? Thanks in advance / Mysore Ganapati. Last edited by ganapati; 09-16-2008 at 05:53 AM. Reason: missing one line |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Using cat is redundant try this:
Code:
while read risk_factor; do # do something with "$risk_factor" done < "$rf_list" |
|
#3
|
||||
|
||||
|
Thanks Franklin,
It worked, but what could be the problem with foreach loop? Can you clear my doubt please? Thanks and Regards / Mysore Ganapati |
|
#4
|
|||
|
|||
|
AFAIK for each loops is used in csh/tcsh scripts but I'm not familiar with it.
Regards |
|
#5
|
||||
|
||||
|
you are mixing shells here. $() is understood by bash/ksh, while foreach is csh/zsh specific. Which shell are you actually using?
|
|
#6
|
|||
|
|||
|
The error message would indicate Bourne-compatible (sh/ksh/bash -- zsh belongs to this group, too, although it does feature a foreach command, similar to csh's).
|
|
#7
|
||||
|
||||
|
Hi Otheus,
I'm using 'csh'. Dont know exactly whether I'm mixing the shells or not! Cheers ~~ / Mysore Ganapati |
||||
| Google The UNIX and Linux Forums |