• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3232
  • Last Modified:

"for" loop in unix c-shell script

hi .

I am well known with gerenal shell scripts .

I want to use "for" loop widly .

for example :

set lines = `cat file | wc -l`
for ($i=0 ; $i <= $lines ; @ i += 1) # you can see I don't know the syntax !!!
begin
...
...
end

I want to have a full example .

I have no time for reading neither LINKS nor MAN .

please send a short example (10 - 20) lines ,
for c-shell format .

if the answer is correct it will be 100 points+A

Talmash
0
Talmash
Asked:
Talmash
  • 3
  • 2
1 Solution
 
SEveCommented:
in cshell u have only foreach statement:
foreach file  ( `ls` )
  wc -l $file
end

if u want to use other shells - sh or ksh:
   for file in *.c ; do wc -l $file ; done

any questions?

seve
0
 
SEveCommented:
if u want c-style for, like
  for (int i = 0; i < 10; ++i)
u should use while (cshell):

set i = 0
while ($i < 10)
  do something
  @ i = $i + 1
end

seve
0
 
TalmashAuthor Commented:
o.k. ,

I 'll try the while loop and return back .

Tal
0
 
TalmashAuthor Commented:
seve

thanks again .

Tal


(if you meet any difficulties in VERILOG/math , you can ask me)
0
 
SEveCommented:
thanks about verilog, but, mostly, i work in software development - no electronics...

seve
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now