Hi Alejandro, On Sat, Feb 27, 2021 at 7:16 PM Alejandro Colomar (man-pages) <alx.manpages@xxxxxxxxx> wrote: [...snip] > >> + find * -type f \ > >> + |grep '\.c$' \ > >> + |sort -V \ > >> + |xargs pcregrep -Mn "(?s)^\w*SYSCALL_DEFINE.\(${1},.*?\)" \ > >> + |sed -E 's/^[^:]+:[0-9]+:/&\n/'; > >> + > >> + find * -type f \ > >> + |grep '\.[ch]$' \ > > > > Any reason not to use "find . -type f -name '*.[ch]'" when you need to > > restrict the files you're looking at? I would expect that to be > > faster. > > I don't like find syntax. I never remember how all of its options work. > grep is much simpler, and everyone knows how it works. > > find has: -[i]lname, -[i]name, -[i]path, -[i]regex, -[i]wholename > I don't want to be reading the manual for all of them each time I use > find. grep does the same with optional -i and some simple regex which > anyone could understand with some basic regex knowledge. 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. > > For the performance part, I don't know; but we might be surprised. At > most it might be a bit faster (nothing like 200%), but I care more about > readability. 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 > > I also avoid using find -exec option, and instead use xargs. It's way > simpler to understand, at least for me. > > See also: > <http://doc.cat-v.org/unix/find-history> > <http://harmful.cat-v.org/cat-v/> Well, I understand the sentiment in those texts, but I would argue that finding files by name is a core functionality of find :). 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.