Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!oliveb!mipos3!omepd!merlyn From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.unix.questions Subject: Re: the care and feeding of fgrep Keywords: fgrep Message-ID: <5282@omepd.UUCP> Date: 28 Nov 89 20:21:29 GMT References: <453@nixba.UUCP> Sender: news@omepd.UUCP Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Hillsboro, Oregon, USA Lines: 48 In-reply-to: mike@nixba.UUCP (Mike Lyons) In article <453@nixba.UUCP>, mike@nixba (Mike Lyons) writes: | This is something that bugs me now and then (before I forget it again :-)... | | The man page for the grep family has the following description for fgrep: | | fgrep [ options ] [ strings ] [ files ] | | The man page also states "Fgrep patterns are fixed strings; it is fast and | compact" My question is, how the heck do you give a list of strings (as im- | plied here) as an arg to fgrep? Every combination of quotes that I've come up | with always results in fgrep treating all but the first string in a list as a | filename, with the accompanying "can't open" complaints. | | When I use fgrep, I invariably put the strings into a file and use the -f | option, but this *really shouldn't* be necessary if the man page is correct. | | Please enlighten me :-) A Zen master will whack you on the side of your head with his stick at that request, but I'll try to be a "kinder, gentler" response. The string arg to fgrep needs *newline*-separated strings, ala: $ fgrep 'root sys merlyn' /etc/passwd ... [output appears here] ... $ If you use the non-syntactically-powerful C-shell, you'll have to escape each newline with a backslash, as in: % fgrep 'root\ sys\ merlyn' /etc/passwd ... [output appears here] ... % There. [look ma... no Perl program... :-] Just another UNIX hacker, -- /== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\ | on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn | \== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/