home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / question / 13759 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  1.1 KB

  1. Path: sparky!uunet!pmafire!news.dell.com!swrinde!sdd.hp.com!think.com!ames!agate!doc.ic.ac.uk!uknet!warwick!warwick!not-for-mail
  2. From: maupb@csv.warwick.ac.uk (Mr J L Saunders)
  3. Newsgroups: comp.unix.questions
  4. Subject: Re: for loop backwards !!!!
  5. Message-ID: <1eo79mINN2vc@clover.csv.warwick.ac.uk>
  6. Date: 22 Nov 92 15:00:06 GMT
  7. References: <1en5jrINN1ui@cumin.csv.warwick.ac.uk>
  8. Organization: Computing Services, University of Warwick, UK
  9. Lines: 27
  10. NNTP-Posting-Host: clover.csv.warwick.ac.uk
  11.  
  12. In article <1en5jrINN1ui@cumin.csv.warwick.ac.uk> cstaddc@csv.warwick.ac.uk (Mr M A Stuart) writes:
  13. %
  14. %
  15. %    How can I do the equivilant of the following for loop under unix.
  16. %
  17. %    for n := top to 1 do
  18. %    commands etc etc
  19. %
  20. %    Thanks for any suggestions !
  21.  
  22. It depends on what shell you are using. In csh (or tcsh) you might do
  23.  
  24. set top=20
  25. set n=top
  26.  
  27. while ($n) 
  28. commands
  29. set n = expr "$n -1"
  30. end
  31.  
  32. Hope that helps...
  33.  
  34. Jason
  35. -- 
  36.                        Jason L Saunders [ RouE ]      
  37.                      email: maupb@csv.warwick.ac.uk
  38. snail: Warwick Business School, University of Warwick, Coventry CV4 7AL, UK
  39.