Results 1 to 6 of 6
hi i am trying to run a for loop in csh, but i don't think that it is possible, the for loop is to loop round say
for (i=0; i<=5; ...
- 06-28-2007 #1Just Joined!
- Join Date
- Jun 2007
- Posts
- 4
for/while loop...awk
hi i am trying to run a for loop in csh, but i don't think that it is possible, the for loop is to loop round say
for (i=0; i<=5; i++){
in here i want to run a file or a pipe to copy a line repeatedly, then save result in a file
}
i am relatively new here and am not sure the correct syntax
i have been trying for hours
do i need to use awk or am i ok in csh
help!
- 06-28-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Welcome to the forum.
Try this:
Awk is not a shell but a text manipulation tool. I should begin with Bash instead of csh.Code:for i = 0 to 4 do # do your stuff here end
Regards
- 06-28-2007 #3
Can I ask why csh? I thought bash was the default shell for just about every Linux distro under the sun. You may find it a lot easier to script with, too.
- 06-28-2007 #4Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
I agree with most other people: use bash, ksh, etc., any of the Bourne shell family is preferable to csh family for scripting.
However, if you must, you may be able to use one of these:
producing:Code:#!/bin/tcsh # @(#) s3 Demonstrate loops in [t]csh. echo echo $version | fold -66 echo echo " foreach loop:" foreach i ( `/usr/bin/seq 0 3` ) echo " i is $i" end echo echo " while loop:" set j = 0 while ( $j < 4 ) echo " j is $j" @ j++ end exit 0
For a host of reasons not to use csh, see:Code:% ./s3 tcsh 6.13.00 (Astron) 2004-05-19 (i386-intel-linux) options 8b,nls ,bye,al,ng,rh,nd,color,filec foreach loop: i is 0 i is 1 i is 2 i is 3 while loop: j is 0 j is 1 j is 2 j is 3
Csh Programming Considered Harmful
Best wishes ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 06-28-2007 #5Just Joined!
- Join Date
- Jun 2007
- Posts
- 4
cheers guys helped, got it working now, can move along nicely
- 06-28-2007 #6Linux User
- Join Date
- Aug 2006
- Posts
- 458


Reply With Quote
