emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#40903: closed (the "ls -R *.pdf" command does not search recursively


From: GNU bug Tracking System
Subject: bug#40903: closed (the "ls -R *.pdf" command does not search recursively only current dir)
Date: Mon, 27 Apr 2020 15:01:02 +0000

Your message dated Mon, 27 Apr 2020 10:00:52 -0500
with message-id <address@hidden>
and subject line Re: bug#40903: the "ls -R *.pdf" command does not search 
recursively only current dir
has caused the debbugs.gnu.org bug report #40903,
regarding the "ls -R *.pdf" command does not search recursively only current dir
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden.)


-- 
40903: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=40903
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: the "ls -R *.pdf" command does not search recursively only current dir Date: Mon, 27 Apr 2020 07:25:25 -0700
Greetings,

I found the ls command when used with a pattern does not search recursively.

ls -R *.pdf 
only searches the current directory and not recursively.

--
Thank you,

Jim Clark

--- End Message ---
--- Begin Message --- Subject: Re: bug#40903: the "ls -R *.pdf" command does not search recursively only current dir Date: Mon, 27 Apr 2020 10:00:52 -0500 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0
tag 40903 notabug
thanks

On 4/27/20 9:25 AM, Jim Clark wrote:
Greetings,

I found the ls command when used with a pattern does not search recursively.

ls -R *.pdf
only searches the current directory and not recursively.

You are forgetting that globs expand prior to invoking ls. What you have invoked is something like:

ls -R a.pdf b.pdf

which says to recursively list all files starting with a.pdf or b.pdf, and descending if any of those files are a directory, but neither a.pdf nor b.pdf is a directory, so there is nothing to descend into.

Instead of trying to mess with how globbing interacts with ls, you are better off learning how to use 'find', which does recursion and filtering as its primary goal. In this case, you would use:

find . -name '*.pdf'

which gives you a recursive listing of all directories under '.', then filters it out to files ending in .pdf.

As the action of globbing is done by your shell and not by ls, there is nothing to change in coreutils, so I'm closing this as not a bug. But feel free to respond with further questions on the topic.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]