Path: utzoo!attcan!uunet!mcvax!ukc!warwick!geoff From: geoff@warwick.UUCP (Geoff Rimmer) Newsgroups: comp.unix.questions Subject: Re: Line at a time scripts in csh Message-ID: <909@ubu.warwick.UUCP> Date: 17 Jan 89 00:40:51 GMT References: <4116@paris.ics.uci.edu> Sender: news@warwick.UUCP Reply-To: geoff@emerald.UUCP (Geoff Rimmer) Organization: Computer Science, Warwick University, UK Lines: 60 In article <4116@paris.ics.uci.edu> posert@bonnie.ics.uci.edu (Bob Posert) writes: > >I have a file with two words on each line, and want to >process them in a shell script, but can't figure out >how to get *the entire line* into a variable. > >I tried: > foreach i (`cat file`) > #misc processing > end >but i was set to each word, not line. > If you do foreach i ("`cat file`") #misc processing end you will get the whole line. However, when I tried this just now, I realised that if there are any wild cards (?,*,[,]) then it gives the strange error message end: No match when it gets to the line containing the ? or whatever. Can anyone explan this one? >Then I tried the same thing, but adding quotes at the beginning and >end of every line in the input file. Basically the same thing happened, >even though from the prompt, > foreach i ("One Two") > echo $i > end >echoed the words on the same line. I suppose when csh interprets the output of the `...` , it ignores the quotes, but I have no idea why it should do so!! Way back in my first year (and most of the second) I was there slaving away at sorting out which quotes to use in csh/sh and when or not to use a backslash etc, and I got so fed up, that I haven't written any scripts since (except for the simplest type) and now everything is in C. OK, it takes a lot longer to write, but it's a lot faster, it's more reliable, and a lot more powerful! > Bob Posert > I'm: posert@bonnie.ics.uci.edu or {sdcsvax|ucbvax}!ucivax!bonnie!posert Geoff ------------------------------------------------------------ Geoff Rimmer, Computer Science, Warwick University, England. geoff@uk.ac.warwick.emerald "It just goes to show, if you want something doing properly, it's best not to drink 16 pints of lager beforehand." - Filthy Rich and Catflap, 1986. ------------------------------------------------------------