All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Alejandro Colomar (man-pages)" <alx.manpages@gmail.com>
To: Stefan Puiu <stefan.puiu@gmail.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>,
	lnx-man <linux-man@vger.kernel.org>, Walter Harms <wharms@bfs.de>
Subject: Re: [PATCH v9] scripts/bash_aliases: Add useful functions
Date: Mon, 1 Mar 2021 15:16:44 +0100	[thread overview]
Message-ID: <c0a29abe-ade4-d79c-31ec-6957de7e9ef0@gmail.com> (raw)
In-Reply-To: <CACKs7VAwN6_ibvEhNsnsNsS6PnncCmjGEuKuBs-P5qMXNw2Vww@mail.gmail.com>



On 3/1/21 11:19 AM, Stefan Puiu wrote:
> On Sat, Feb 27, 2021 at 7:16 PM Alejandro Colomar (man-pages)

> I've always used find -name, I think most of the time it's enough. But
> I can understand that people might prefer writing certain snippets in
> a certain way, and you need to be comfortable with scripts you are
> maintaining.

Yes
> 
> Actually, as far as I can tell there's not much difference
> performance-wise between the two, as far as I can tell. At least when
> searching the kernel source on my Linux VM. So it seems I'm wrong on
> that point:
> 
> stefan@spuiu-vm:~/rpmbuild/BUILD/kernel-3.10.0-1160.2.2.el7/linux-3.10.0-1160.2.2.el7.x86_64$
> time ( find . | grep '\.c' &>/dev/null )
> 
> real    0m0.076s
> user    0m0.031s
> sys     0m0.046s
> stefan@spuiu-vm:~/rpmbuild/BUILD/kernel-3.10.0-1160.2.2.el7/linux-3.10.0-1160.2.2.el7.x86_64$
> time ( find . -name  '*.c' &>/dev/null )
> 
> real    0m0.088s
> user    0m0.016s
> sys     0m0.066s

It seems that in real time, piping to grep is even faster than using 
find options :-)

Nevertheless, pcregrep is the bottleneck in these functions.  So I guess 
it would make absolutely no difference.


> 
> Well, I understand the sentiment in those texts, but I would argue
> that finding files by name is a core functionality of find :).

Yes, it is.  However, I think the following applies to grep and find:

"The use of cat to feed a single input file to a program has to some 
degree superseded the shell’s < operator, which illustrates that 
general-purpose constructs --\x14like cat and pipes\x14-- are often more 
natural than convenient special-purpose ones."  [Program design in the 
UNIX(TM) environment]

At least to me, knowing the more general-purpose grep, is easier than 
learning the special purpose find -name :-)

However, the filename options to find may be necessary in some specific 
cases, so I'm not blaming them, only their syntax.  And as long as my 
use cases are simple enough to work with grep, I'll keep using it.

> It's
> true that other extra functionality might not be exactly warranted,
> and yes, '-print' feels kind of weird.
> 
> Thanks for bearing with me,
> Stefan.
> 

You're welcome!  Thanks for commenting on my scripts! :-}

Cheers,

Alex

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/

      reply	other threads:[~2021-03-01 14:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 13:15 [PATCH] scripts/bash_aliases: Add useful functions Alejandro Colomar
2021-02-15 13:36 ` Alejandro Colomar (man-pages)
2021-02-15 20:31 ` Alejandro Colomar
2021-02-15 20:32 ` [PATCH v3] " Alejandro Colomar
2021-02-16 10:54   ` AW: " Walter Harms
2021-02-16 11:00     ` Alejandro Colomar (man-pages)
2021-02-18 18:47 ` [PATCH v4] " Alejandro Colomar
2021-02-18 19:33 ` [PATCH v5] " Alejandro Colomar
2021-02-18 21:17 ` [PATCH v6] " Alejandro Colomar
2021-02-19 14:13 ` [PATCH v7] " Alejandro Colomar
2021-02-19 14:22 ` [PATCH v8] " Alejandro Colomar
2021-02-19 14:32 ` [PATCH v9] " Alejandro Colomar
2021-02-20 14:35   ` Michael Kerrisk (man-pages)
2021-02-20 21:45   ` Michael Kerrisk (man-pages)
2021-02-27 15:09   ` Stefan Puiu
2021-02-27 17:16     ` Alejandro Colomar (man-pages)
2021-03-01 10:19       ` Stefan Puiu
2021-03-01 14:16         ` Alejandro Colomar (man-pages) [this message]

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=c0a29abe-ade4-d79c-31ec-6957de7e9ef0@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=linux-man@vger.kernel.org \
    --cc=mtk.manpages@gmail.com \
    --cc=stefan.puiu@gmail.com \
    --cc=wharms@bfs.de \
    /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.
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.