Solved

"for" loop in unix c-shell script

Posted on 2001-06-03
5
3,173 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wait notify demo infinite loop 3 121
sumHeights  challenge 17 73
Is there a simple front-end menu system. 9 102
Increment column based of a FK 8 31
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.

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