coreutils
[Top][All Lists]
Advanced

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

Re: Determination of file lists from selected folders without returning


From: Eric Blake
Subject: Re: Determination of file lists from selected folders without returning directory names
Date: Mon, 17 Jul 2017 14:42:03 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/17/2017 02:03 PM, SF Markus Elfring wrote:
>>> The tool “ls” supports the filtering of directory contents. I am looking for
>>> possibilities for performing such data processing a bit faster when 
>>> directory
>>> names can (and should) be excluded.
>>
>> If you use GNU findutils:
>>
>> find -maxdepth 1 \! -type d
>>
>> if you want to stick to POSIX find, you'll have to be a bit more verbose
>> and use -prune.
> 
> The result does not look in the way I was looking for when I try the command
> “find ~/Projekte/Bau -name '*txt' -prune” or

Are you sure that does what you want?  It prunes only directories named
'*txt' (if there are any).

> “find ~/Projekte/Bau -name '*txt' \! -type d” out.
> 
> 
> Does any programming interface exist already which will provide only
> basenames for the found files directly?

Again, if you are using GNU find, then the -printf directive is your
friend.  If you are trying to use just POSIX tools, then you have to
pipeline together multiple tools to get the same effect.

Please, help us help you.  Give us a sample directory layout, along with
sample output that you are hoping to produce from it.  Chances are,
existing tools can do what you want, but having a concrete example in
front of us instead of a vague request will make it easier (and
hopefully you aren't trying to use us to answer a homework problem for you).

For example, I can do:

$ mkdir -p a/b
$ touch a/f1 a/f2.txt a/b/f3 a/b/f4.txt
$ find a -maxdepth 1 \! -type d -printf %f\\n
f1
f2.txt

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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