Cshell question: taking wordlists as a single string

Brad Appleton brad at SSD.CSD.HARRIS.COM
Fri Aug 17 01:26:41 AEST 1990


In article <3251 at syma.sussex.ac.uk> andy at syma.sussex.ac.uk (Andy Clews) writes:

In article <3251 at syma.sussex.ac.uk> you write:
> The difficulty arises because I want to do (for example)
>
>	whatnews "bug reports"
>
>where the intended effect is to search out all lines containing the
>string "bug reports". At the moment it splits this up into "bug" and
>"reports" and does two searches. This is because the script contains a
>      foreach i ($*)
>loop for repeated searches.  Quoting (single or double) doesn't help.

Dont use "$*" in this case, use $argv and a while loop!
The following should work in the manner you desire:

	@ i=1
	while ( $i <= $#argv )
	  cmd "$argv[$i]"   ##dont forget those quotes!
	    .
	    .
	    .
	  @ i++
	end

Im sure there are other solutions too (probably better ones) but this
works (on my machone anyway) and should be easy to understand.
Any other solutions out there?

hope this helps!
______________________ "And miles to go before I sleep." ______________________
 Brad Appleton        brad at travis.ssd.csd.harris.com   Harris Computer Systems
                          ...!uunet!hcx1!brad          Fort Lauderdale, FL USA
~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~



More information about the Comp.unix.questions mailing list