From: Tom Roche <Tom_Roche@pobox.com>
To: help-gnu-emacs@gnu.org,
Subject: Re: grep-find oddity
Date: Mon, 22 Mar 2010 12:56:09 -0400 [thread overview]
Message-ID: <87mxy0thw6.fsf@pobox.com> (raw)
In-Reply-To: <83tys9gft8.fsf@gnu.org>
[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 '<respiratory>'"
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".
<auto-dopeslap/> 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 '<respiratory>'
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 '<respiratory>'
> ./logfile.100103:326:<respiratory>
> ./logfile.100110:529:<respiratory>
> ./logfile.100117:217:<respiratory>
> ./logfile.100124:186:<respiratory>
> ./logfile.100131:387:<respiratory>
> ./logfile.100207:836:<respiratory>
> ./logfile.100214:271:<respiratory>
> ./logfile.100221:402:<respiratory>
> ./logfile.100228:311:<respiratory>
> ./logfile.100307:265:<respiratory>
> ./logfile.100314:488:<respiratory>
> ./logfile.100321:731:<respiratory>
>
> 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 '<respiratory>'
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 '<respiratory>'
> ./logfile.100103:326:<respiratory>
> ./logfile.100110:529:<respiratory>
> ./logfile.100117:217:<respiratory>
> ./logfile.100124:186:<respiratory>
> ./logfile.100131:387:<respiratory>
> ./logfile.100207:836:<respiratory>
> ./logfile.100214:271:<respiratory>
> ./logfile.100221:402:<respiratory>
> ./logfile.100228:311:<respiratory>
> ./logfile.100307:265:<respiratory>
> ./logfile.100314:488:<respiratory>
> ./logfile.100321:731:<respiratory>
>
> 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 <Tom_Roche@pobox.com>
next prev parent reply other threads:[~2010-03-22 16:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-22 3:38 grep-find oddity Tom Roche
2010-03-22 4:07 ` Eli Zaretskii
2010-03-22 16:56 ` Tom Roche [this message]
2010-03-22 17:49 ` Suvayu Ali
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87mxy0thw6.fsf@pobox.com \
--to=tom_roche@pobox.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.