From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Roche Newsgroups: gmane.emacs.help Subject: Re: grep-find oddity Date: Mon, 22 Mar 2010 12:56:09 -0400 Message-ID: <87mxy0thw6.fsf@pobox.com> References: <87pr2xt49y.fsf@pobox.com>, <83tys9gft8.fsf@gnu.org> Reply-To: help-gnu-emacs@gnu.org, Tom Roche NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1269277012 27459 80.91.229.12 (22 Mar 2010 16:56:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Mar 2010 16:56:52 +0000 (UTC) To: help-gnu-emacs@gnu.org, Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Mar 22 17:56:48 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ntkvn-0002n1-AT for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Mar 2010 17:56:47 +0100 Original-Received: from localhost ([127.0.0.1]:41670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ntkvm-0007It-Od for geh-help-gnu-emacs@m.gmane.org; Mon, 22 Mar 2010 12:56:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NtkvM-0007Ig-UH for help-gnu-emacs@gnu.org; Mon, 22 Mar 2010 12:56:20 -0400 Original-Received: from [140.186.70.92] (port=49626 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtkvG-0007H4-Ak for help-gnu-emacs@gnu.org; Mon, 22 Mar 2010 12:56:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NtkvE-0007qZ-R3 for help-gnu-emacs@gnu.org; Mon, 22 Mar 2010 12:56:14 -0400 Original-Received: from b-pb-sasl-quonix.pobox.com ([208.72.237.35]:34352 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NtkvE-0007qV-Mn for help-gnu-emacs@gnu.org; Mon, 22 Mar 2010 12:56:12 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 3EEDB97A75; Mon, 22 Mar 2010 12:56:12 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to :subject:in-reply-to:references:reply-to:date:message-id :mime-version:content-type; s=sasl; bh=xtr3YtDbxdVyYMwHEdPtjsDN/ 1Y=; b=PGr08Yd87E/CFkGJpL8GxerJvSR9wuVyCpr7Dj3zl1bYmerNmfRcKSZVE mhWoaZelqr/z2GR5Vz/X/vbqcv2avDhYAkoR4Gs9LtX9WmthzaUXWdZWlkxU5gOz Z4KMzHPmgT2bPDmgYJhqNyq/jbvHvQ8tyRvdjjGZploedyo3U0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:subject :in-reply-to:references:reply-to:date:message-id:mime-version :content-type; q=dns; s=sasl; b=V7FzS9e6Yp7NAVWD8NAJAFTiCr/BC9Lv p1o7evsVY0DMOs/kKdO3XLTC0Yt/+GLPpnI2ZPg4GRl1U66XXIYjT02k9u4/neH7 vpNKkoIAp0rFQrb45w/8Lm9psEoH4HbbdAMhT5gvsa4UX1oIbpGW69CuF+eT3xS0 bj47jib7rak= Original-Received: from b-pb-sasl-quonix. (unknown [127.0.0.1]) by b-sasl-quonix.pobox.com (Postfix) with ESMTP id 2B95697A74; Mon, 22 Mar 2010 12:56:11 -0400 (EDT) Original-Received: from tlrPanP5.pobox.com (unknown [69.134.240.67]) by b-sasl-quonix.pobox.com (Postfix) with ESMTPA id 9F1CC97A72; Mon, 22 Mar 2010 12:56:09 -0400 (EDT) In-Reply-To: <83tys9gft8.fsf@gnu.org> User-Agent: GNU Emacs 23.1.50.1 (x86_64-pc-linux-gnu, GTK+ Version 2.18.0) X-Pobox-Relay-ID: D15FF2C4-35D3-11DF-9016-68E3016DD5F0-07218935!b-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:72449 Archived-At: [thread regarding perceived oddity of behavior of M-x grep-find argument="find . -type f -name '*.10*' -print0 | sort | xargs -0 -e fgrep -nH -e ''" starts @ http://lists.gnu.org/archive/html/help-gnu-emacs/2010-03/msg00181.html ] Eli Zaretskii Mon, 22 Mar 2010 06:07:15 +0200 > Try "sort -z" instead of just "sort". Thanks! I should have noted the semantics of -print0. Of course, M-x grep-find with find . -type f -name '*.10*' -print0 | sort -z | xargs -0 -e fgrep -nH -e '' gets the desired result *grep* > -*- mode: grep; default-directory: "~/info/logs/" -*- > Grep started at Mon Mar 22 12:31:07 > > find . -type f -name '*.10*' -print0 | sort -z | xargs -0 -e fgrep -nH -e '' > ./logfile.100103:326: > ./logfile.100110:529: > ./logfile.100117:217: > ./logfile.100124:186: > ./logfile.100131:387: > ./logfile.100207:836: > ./logfile.100214:271: > ./logfile.100221:402: > ./logfile.100228:311: > ./logfile.100307:265: > ./logfile.100314:488: > ./logfile.100321:731: > > Grep finished (matches found) at Mon Mar 22 12:31:07 Note that the default argument offered for grep-find uses -print0. I'm wondering, why? since invoking find . -type f -name '*.10*' -print | sort | xargs -e fgrep -nH -e '' also works: *grep* > -*- mode: grep; default-directory: "~/info/logs/" -*- > Grep started at Mon Mar 22 12:36:06 > > find . -type f -name '*.10*' -print | sort | xargs -e fgrep -nH -e '' > ./logfile.100103:326: > ./logfile.100110:529: > ./logfile.100117:217: > ./logfile.100124:186: > ./logfile.100131:387: > ./logfile.100207:836: > ./logfile.100214:271: > ./logfile.100221:402: > ./logfile.100228:311: > ./logfile.100307:265: > ./logfile.100314:488: > ./logfile.100321:731: > > Grep finished (matches found) at Mon Mar 22 12:36:06 Using the special null-string-terminating argument to 'find' without subsequent use with *all* further components of the pipeline the user might want to build (e.g. '-z' with 'sort', '-0' with 'xargs') will result in error (e.g. no results, or no linkage from the results to the underlying files). Thus the default offered seems (to me, and I Could Be Wrong) to be a likely source of error. Am I missing something? Or is there an overriding motivation for making null-string termination the default? thanks for the tip, Tom Roche