Solved

"for" loop in unix c-shell script

Posted on 2001-06-03
5
3,135 Views
Last Modified: 2013-12-26
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
Comment
Question by:Talmash
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:SEve
Comment Utility
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
 
LVL 3

Accepted Solution

by:
SEve earned 50 total points
Comment Utility
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
 
LVL 6

Author Comment

by:Talmash
Comment Utility
o.k. ,

I 'll try the while loop and return back .

Tal
0
 
LVL 6

Author Comment

by:Talmash
Comment Utility
seve

thanks again .

Tal


(if you meet any difficulties in VERILOG/math , you can ask me)
0
 
LVL 3

Expert Comment

by:SEve
Comment Utility
thanks about verilog, but, mostly, i work in software development - no electronics...

seve
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now