From owner-freebsd-questions@FreeBSD.ORG Thu Aug 12 18:06:06 2010 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C11631065672 for ; Thu, 12 Aug 2010 18:06:06 +0000 (UTC) (envelope-from prvs=08336d2004=johnl@iecc.com) Received: from gal.iecc.com (gal.iecc.com [64.57.183.53]) by mx1.freebsd.org (Postfix) with ESMTP id 518648FC17 for ; Thu, 12 Aug 2010 18:06:05 +0000 (UTC) Received: (qmail 97550 invoked from network); 12 Aug 2010 18:06:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=iecc.com; h=date:message-id:from:to:subject:in-reply-to:references:mime-version:content-type:user-agent:cleverness; s=k1008; bh=FQT1Gt6ZvgOBc1mbNIiz4w3r9qrxyXhwaOIb79BME4M=; b=XEV9pC3nMrsZVgbAQeR8ePwWn0T7Nc26HJB2QbWE2JHmVn7JI+vLfc6Vfc4/NOWB3rMM2VQPGDJj0Tg/O7fuSOabdWNLK4DTdYb/IvtVTH3fE6HhriwPgV+9LgjIwPj6gXoHnOV154UDVP2tFnYc/rTKIq0fR6Hs7qNgHmNMDjk= Received: (ofmipd 64.57.183.62) with (DHE-RSA-AES256-SHA encrypted) SMTP; 12 Aug 2010 18:05:43 -0000 Date: 12 Aug 2010 14:06:04 -0400 Message-ID: From: "John R. Levine" To: freebsd-questions@FreeBSD.ORG, jacks@sage-american.com In-Reply-To: <201008121644.o7CGiflh099466@lurza.secnetix.de> References: <201008121644.o7CGiflh099466@lurza.secnetix.de> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) Cleverness: None detected MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Subject: Re: Grepping a list of words X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2010 18:06:06 -0000 > > Gee, 50 words, that's about a 300 character pattern, that's not a problem > > for any shell or version of grep I know. > > > > But reading the words from a file is equivalent and as you note most > > likely easier to do. > > The question is what is more efficient. This might be > important if that kind of grep command is run very often > by a script, or if it's run on very large files. It's exactly the same, since it's the same program using the same search algorithm. The only thing that's different is the input language for the pattern. What looks like a bunch of separate patterns in the input file is internally turned into one pattern that is then compiled into a state machine that it uses to match the input. R's, John