Solved

"for" loop in unix c-shell script

Posted on 2001-06-03
5
3,166 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
ID: 6150700
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
ID: 6150807
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
ID: 6151883
o.k. ,

I 'll try the while loop and return back .

Tal
0
 
LVL 6

Author Comment

by:Talmash
ID: 6155855
seve

thanks again .

Tal


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

Expert Comment

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

seve
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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