Path: utzoo!attcan!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.questions Subject: Re^2: Line at a time scripts in csh Message-ID: <1905@solo2.cs.vu.nl> Date: 16 Jan 89 15:36:26 GMT References: <3715@crash.cts.com> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 37 marquez@pnet01.cts.com (Dan Castro) writes: \maart@cs.vu.nl (Maarten Litmaath) writes: \>foreach i ("`cat file`") # create 1 string \> ..."$i"... # avoid * and friends getting expanded \>end \... The script shown above didn't work on my system. It should work, due to a csh quirk; the Bourne shell will create 1 string containing the complete file, whereas csh processes each line seperately: for i in "`cat file`" do ... done won't do what was intended; leaving out the quotes doesn't help either. \(Microport V/AT 286 2.3) The following did work for both the Bourne \and c shells... Yeah? I guess you've got a problem: portability. :-) [ long *Bourne shell* script deleted ] Here's my solution: #! /bin/awk -f { print $0, $2, $1 } Cute, not? I love it when a plan comes together. If your UNIX version doesn't recognize the `#!' magic number: /bin/awk '{ print $0, $2, $1 }' $* -- Lee Harvey Oswald was a patsy. |Maarten Litmaath @ VU Amsterdam: Or a superman. |maart@cs.vu.nl, mcvax!botter!maart