Solved

"for" loop in unix c-shell script

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 106
Strange date stored 22 169
string initialization in java 11 117
viewing source code from eclipse 13 110
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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