Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!paperboy!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!htsa!maestro!miquels From: miquels@maestro.htsa.aha.nl (Miquel van Smoorenburg) Newsgroups: comp.unix.shell Subject: Re: for loops Keywords: sh: for i to $FILES Message-ID: <2816@maestro.htsa.aha.nl> Date: 4 Apr 91 13:34:15 GMT References: <3693@ux.acs.umn.edu> Sender: bin@htsa.htsa.aha.nl Organization: AHA-TMF, Polytechnical Institute, Amsterdam, The Netherlands Lines: 24 In article <3693@ux.acs.umn.edu> edh@ux.acs.umn.edu (Merlinus Ambrosius) writes: >In sh, I'd like to do something like a BASIC for loop. Say I have $FILES >set to some number, and I'd like to go through a loop $FILES times. Can >this be done in sh? POSIX states that sh(1) should be able to evaluate expressions, so you can do something like while [ $FILES != 0 ] do echo -n '* ' FILES=$[$FILES - 1] done But I haven't seen a sh anywhere that is already capable of doing this (not even the one I am writing myself for Minix... yet.). Maybe somebody knows if a new ksh can do this? -- +===============================+============================================+ | | | | Miquel van Smoorenburg, | It's nice to be important, | | miquels@maestro.htsa.aha.nl | but it's more important to be nice. | | | | +===============================+============================================+