Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!think.com!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!axion!delluk!robobar!ronald From: ronald@robobar.co.uk (Ronald S H Khoo) Newsgroups: comp.unix.shell Subject: Re: for loops Message-ID: <1991Apr7.125534.20656@robobar.co.uk> Date: 7 Apr 91 12:55:34 GMT References: <3693@ux.acs.umn.edu> <1991Apr3.213023.23397@athena.mit.edu> Organization: Robobar Ltd., Perivale, Middx., ENGLAND. Lines: 20 rich@pencil.cs.missouri.edu (Rich Winkel) writes: > FILES=10 > for i in `head -$FILES /usr/dict/words` Hee hee. Neat hack. I got a feeling that my boss would be very unhappy if I used that in production code though :-) But I like it. > I guess someone's going to tell me now that 'head' isn't standard unix? Yes, but unless you're head'ing more than one file, sed q is the same as head -n, so you could have avoided the use of that disclaimer, had you said: for i in `sed ${FILES}q /usr/dict/words` Also, if no shell variables are involved, sed 10q is less to type than head -10 :-) -- Ronald Khoo +44 81 991 1142 (O) +44 71 229 7741 (H)