On Tue, Sep 12, 2023 at 6:13 PM raf wrote:
>
> On Tue, Sep 12, 2023 at 06:39:32PM +0200, Andreas Metzler
> wrote:
>
> > On 2023-09-12 Peng Yu wrote:
> > > Hi,
> >
> > > How to find directories that only contain a certain type of files (e.g.,
> &g
Hi,
How to find directories that only contain a certain type of files (e.g., .txt)?
One idea that I have is to just search for all files' paths. Then use
a post-processing script to analyze which directories only contain
files of a certain type (e.g., .txt extension).
Does anybody have a better
On Sun, Mar 28, 2021 at 4:31 AM Bernhard Voelker
wrote:
>
> On 3/27/21 10:16 PM, James Youngman wrote:
> > Personally, I would probably use -delete to avoid the overhead of -exec
> > entirely (the explicit -depth is essentially only there for documentation):
> >
> > find . -depth \( -path '*0/*'
Hi,
If just find is used, the following error will be printed. There are
many ways to solve this problem.
$ mkdir -p {x..z}/0/
$ touch {x..z}/0/1.txt
$ find -name 0 -delete
find: cannot delete ‘./z/0’: Directory not empty
find: cannot delete ‘./x/0’: Directory not empty
find: cannot delete ‘./y/0
Hi,
I want to suppress the message "xargs: ls: terminated by signal 13".
$ find . -type f | xargs ls -altr | head
...
xargs: ls: terminated by signal 13
I could use this. But I don't want to miss other error messages. Is
there an option of xargs to just suppress this message? Thanks.
$ find . -
Hi,
I don't find `find` has an option to limit the entries to print only
to the first n entries. Is there such an option available? Thanks.
--
Regards,
Peng
It seems that +1 includes 1 block. Is it so?
If it is the case, then it is not consistent with +1c which does not
include 1c? Thanks.
On 5/10/20, Andreas Metzler wrote:
> On 2020-05-10 Peng Yu wrote:
>> Hi,
>
>> I only see find's --size support + and - which means >
Hi,
I only see find's --size support + and - which means > or <. Is there
a way to search for >= or <=? Thanks.
--
Regards,
Peng
OK. So this will make sure `/d1/d2/d3` will not be searched multiple
times? Or it is still searched when `/d1/d2`, `/d1` or `/` is
searched?
On 4/12/20, Bernhard Voelker wrote:
> On 2020-04-11 12:19, Peng Yu wrote:
>> Recursive also means subdirectories, sub subdirectories, etc.
>
Recursive also means subdirectories, sub subdirectories, etc.
On Sat, Apr 11, 2020 at 4:17 AM Bernhard Voelker
wrote:
> On 2020-04-10 19:29, Peng Yu wrote:
> > On 4/10/20, Bernhard Voelker wrote:
> >> ---8<---8<---8<---8<---8<---8<---8<---8<---8<
Thanks. I will need to search the parent directory recursively. Does
this code only search whether a file is in a parent their parents,
etc., but not recursively for a given ancestor?
On 4/10/20, Bernhard Voelker wrote:
> On 2020-04-10 16:09, Peng Yu wrote:
>> Hi,
>>
>> I
Hi,
I'd like to look for a file by its name in the current directory. If
not found, go the the parent and look for it again. If not go up one
level again and look for it, ... until it is found (or until a given
level is reached). If the file is not found, return an error.
The resulted path should
I don't think the `xargs -n 4` in the middle is robust. For example,
when the input contains spaces, it won't work as expected. Is there a
way to make it robust?
$ printf '%s\n' {a..d} | xargs -n 4
a b c d
$ printf '%s\n' 'a b' 'c d' 'e f' 'g h' | xargs -n 4
a b c d
e f g h
On 3/8/20, James Y
Instead of manually specify -n that is a multiple of m which could
overflow, maybe xargs should have an additional argument to allow -n
be the maximum allowable multiple of m?
> $ seq 100 | xargs -n $(( 5 * 2000 )) printf '%s\t%s\t%s\t%s\t%s\n'
> /tmp/1.txt
> $ < /tmp/1.txt awk -e '!($1 &&
No. I have a program that expects m*n arguments instead of just m (n
is an interger). Using `xargs -n m` would make calling the program too
many times.
On 2/21/20, Bernhard Voelker wrote:
> On 2020-02-20 20:46, Peng Yu wrote:
>> Hi,
>>
>> xargs by default does not put a mu
Hi,
xargs by default does not put a multiple of m arguments (m is an
integer greater than 1) to the command line. But is there a way that I
can make sure only a multiple of m arguments are put the command line.
For example, for something like the following command, I'd like to
make sure everytime
Hi,
I'd like to make sure the `find -printf '%P\n'` output of a directory
(i.e., only relative paths are printed) be consistent among different
runs as long as the file paths in the directory are the same.
I can pass the `find` output to `sort`. Is it the best way to do so? Thanks.
--
Regards,
Hi,
Sometimes, I'd like to know whether there is nothing found. Is there a
way to let find return none-zero when nothing is found? Thanks.
--
Regards,
Peng
wrote:
> On 2019-09-27 17:26, Peng Yu wrote:
> > On 2019-09-27 09:49, Stephane Chazelas wrote:
> >> Here, you could do:
> >>
> >> find . -type d -exec test -e '{}/file.txt' \; -prune -printf
> '%p/file.txt\n'
> >>
> >>
But wouldn't a scripting language be less efficient than C implementation?
I am not sure the time saved by traverse fewer files using pruning
will be greater than the time wasted in using a scripting language.
I'd like to know this beforehand before I create a custom
implementation in a scripting
Hi,
I'd like to find files named `file.txt` recursively. But the directory
structure has a property that if any directory has a file `file.txt`,
any of its subdirectories will not have file.txt anymore.
Therefore, the quickest way to `find` is to stop descending into
subdirectories if their ances
> That also depends on a few other factors like .e.g. "env headroom', see
> https://git.sv.gnu.org/cgit/findutils.git/tree/xargs/xargs.c#n427
> from line 427 until line 510.
>
> I don't have Mac OS X, so I can't step through what's the limiting factor
> in your case.
>
> What's your actual concer
On Thu, Nov 8, 2018 at 4:50 AM Bernhard Voelker
wrote:
>
> On 11/8/18 6:50 AM, Peng Yu wrote:
> > Hi,
> >
> > It seems that the default value for --max-args is system dependent. Is
> > there a way to find out its default value? Thanks.
>
> Actually the li
Hi,
It seems that the default value for --max-args is system dependent. Is
there a way to find out its default value? Thanks.
--
Regards,
Peng
>
>
> glusterfs doesn't provide D_TYPE information:
>
> getdents(4, {{d_ino=10054722685526780333, ..., d_type=DT_UNKNOWN} ...
>
> Nevertheless, it is strange that find calls newfstatat() also
> in the case of "-maxdepth 1" - it shouldn't need to.
Should this be considered as a performance bug of
> Is your find binary built with D_TYPE support?
>
> $ find --version
> find (GNU findutils) 4.6.0
> Copyright (C) 2015 Free Software Foundation, Inc.
> ...
> Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION
> FTS(FTS_CWDFD) CBO(level=2)
> ^^
$ find
1 getppid
0.000.00 0 1 getpgrp
-- --- --- - -
100.000.012473 144757 total
On Wed, Jan 24, 2018 at 1:39 AM, Bernhard Voelker
wrote:
> On 01/24/2018 01:44 AM, Peng Y
Hi,
There are ~7000 .txt files in a directory on glusterfs. Here are the run
time of the following two commands. Does anybody know why the find command
is much slower than *.txt? Is there a way to change the API that `find`
uses to search files so that it can be more friendly to
glusterfs?
$ time
On Tue, Jun 2, 2015 at 5:50 PM, Morgan Weetman wrote:
>
> Hi Peng,
>
> if you read the man page the behaviour is defined (note the "one or more
> times"):
>
> -
> xargs reads items
> from the standard input, delimited by blanks (which can be protected
> with double or singl
The following command will call ls. But since there is no input,
shouldn't xargs quit without doing anything? Thanks.
xargs -0 ls
On Sat, Apr 18, 2015 at 11:13 AM, Eric Blake wrote:
> On 04/18/2015 10:02 AM, Peng Yu wrote:
>> Hi,
>>
>> I don't see there is a way to search for symlinks pointing to
>> directories natively in find.
>>
>> This can be done by using -exec and test. Bu
Hi,
I don't see there is a way to search for symlinks pointing to
directories natively in find.
This can be done by using -exec and test. But I want to avoid using
-exec. Is there a way to such a search natively in find? Thanks.
-type c
File is of type c:
b
On Thu, Apr 16, 2015 at 1:26 AM, Bernhard Voelker
wrote:
> On 04/16/2015 06:04 AM, Peng Yu wrote:
>> Hi, The following code shows that -prune when used with -exec can be
>> very slow. Is there somehow a way to speed this up?
>>
>> ~$ cat main.sh
>> #!/usr/bin/
Hi, The following code shows that -prune when used with -exec can be
very slow. Is there somehow a way to speed this up?
~$ cat main.sh
#!/usr/bin/env bash
tmpdir=$(mktemp -d)
function mkalotdir {
local n=$1
local i
local j
local k
for i in $(seq -w "$n")
do
for j in $(seq -w "$n")
do
fo
Hi, It seems that it might be convenient to allow `find` to use
exported functions from shell for -exec*? Can this feature be added in
the future?
--
Regards,
Peng
For my case, it is about 10% time difference.
On Wednesday, March 25, 2015, Bernhard Voelker
wrote:
> On 03/25/2015 11:39 PM, Peng Yu wrote:
> > I find that "-exec test ..." can be slower than "-exec $(which test)
> > ...". Is possible that `find` internally u
Hi,
I find that "-exec test ..." can be slower than "-exec $(which test)
...". Is possible that `find` internally use "which", so that users
don't need to explicitly call it? Thanks.
--
Regards,
Peng
Hi,
The following code shows that if a directory has single quote in the
name, it does not work. Does anybody know what the correct way is to
use -exec to test when there is single quote in the command? Thanks.
/tmp/tryfind$ find . -type f
./'/.export
/tmp/tryfind$ find . -type d -exec sh -c "tes
The point is not to call an external program. For example, if there is
a `find` tool made in python, so that I can specify a python
expression to the tool (to replace the function from the external
program), then everything will be run within one process, which avoid
the spawning of new processes.
Hi,
I'm wondering if there is a faster version of `find` (may be in other
languages, such as python or perl).
`-exec` of `find` calls for an external command, which is slow.
If `find` can be implemented in, say, python, then I can use a native
python expression for `-exec`. This should dramatica
> find . \( -type d -exec test -e {}/.ignore \; -prune \) -o
>
> will do something like what you want. But, again, it's not
> efficient, since it performs one fork/exec per subdirectory. A more
I think that given the current wide availability of multicore, if
'find' can take make a multi
Hi,
I don't want to let find search directories with a file .ignore (i.e.,
anything in the directory (including the subdirectories) is ignored).
Is there an efficient way to customize find in this way? (I can think
of an simple way---recursively call "find" with maxdepth 1 and not go
into director
Hi,
I find that things like '%H' of -printf is very hard to remember. Is
there an easy way to remember '%*'?
--
Regards,
Peng
Hi,
/tmp/main$ find . -path '*/tmp*'
/tmp/main$ find /tmp/main -path '*/tmp*'
/tmp/main
The above commands show that -path match the whole path (/tmp/main)
rather than the relative path ('.'). Is there a way to always use the
relative path so that both of the above commands returns nothing?
--
Hi,
I want find all the files that satisfy one set of conditions in
directories that satisfies another set of conditions in one 'find'
command. As an example, I want to search for executables in
directories that has a file named ".export".
As of now, I use the follow commands (to demonstrate idea
Hi,
I'm wondering if there is an easy way to ignore all directories (and
their subdirectories) that contain a certain file.
For example, I have directories blah/a/ blah/a/b. I have
blah/a/.ignore, so blah/a and everything in it are ignored.
--
Regards,
Peng
> Yes. It's explained in the Texinfo documentation for find.
I see the word 'birth' appears in the following two places.
-newerXY reference
Compares the timestamp of the current file with reference. The
reference argument is normally the name of a file (an
Hi,
stat can give birth time. Is there an option search by birth time in
find? (I find -ctime -atime -mtime but not -btime in find.)
--
Regards,
Peng
Hi,
I'm not able to find an argument so that find will only return the
first match then quit. Could you please let me know if there is such
an option?
--
Regards,
Peng
On Tue, Nov 8, 2011 at 12:07 PM, Andreas Metzler
wrote:
> On 2011-11-08 Peng Yu wrote:
>> I see that updatedb is a bash script after I compiled the source. But
>> updatedb in ubuntu is a binary. I'm wondering where the binary
>> updatedb in ubuntu comes from?
>
&g
Hi,
I see that updatedb is a bash script after I compiled the source. But
updatedb in ubuntu is a binary. I'm wondering where the binary
updatedb in ubuntu comes from?
--
Regards,
Peng
On Tue, Nov 8, 2011 at 3:40 AM, James Youngman wrote:
> On Tue, Nov 8, 2011 at 12:11 AM, Peng Yu wrote:
>> On Mon, Nov 7, 2011 at 5:47 PM, James Youngman wrote:
>>> You can achieve this by using locate --regex.
>>
>> Suppose I want to restrict the search to /tm
On Mon, Nov 7, 2011 at 5:47 PM, James Youngman wrote:
> On Mon, Nov 7, 2011 at 10:02 PM, Peng Yu wrote:
>> Hi,
>>
>> For 'find', I can specify which directory (directories) to perform the
>> search. It seems that there is no such an option for 'lo
Hi,
For 'find', I can specify which directory (directories) to perform the
search. It seems that there is no such an option for 'locate' to
restrict the search to certain directory rather than everything in the
database (specified by -d).
Also 'find' offer the option -type, which allows me to sea
Hi,
By default, find will look for all the matches. Is there a way to let
find only get the first match and then return?
--
Regards,
Peng
On Fri, Aug 5, 2011 at 4:46 PM, James Youngman wrote:
> On Fri, Aug 5, 2011 at 10:44 PM, Peng Yu wrote:
>> Hi,
>>
>> I'm wondering if there is a way to speed up find by create some kind
>> of indexing. When the directory structure is large, find becomes slow.
Hi,
I'm wondering if there is a way to speed up find by create some kind
of indexing. When the directory structure is large, find becomes slow.
--
Regards,
Peng
Hi,
The manpage of updatedb only shows the case when one source directory
is used. But I have multiple directories need to be indexed. Is there
a way to do so in updatedb?
updatedb -l 0 -o db_file -U source_directory
--
Regards,
Peng
I know that 'find' start from a dir then recursively check subdirectories.
But I have an application, in which I need to check the start
directory first then check the parent directory (I want to control
whether to go to sibling directories) then the grandparent directory
(I want to control whethe
Hello,
I want to find all the directories that do not have any file in them
(there can be directories in them). Could you show me how to do it?
--
Regards,
Peng
I know -type d is for directory. But how to find directory as well as
symbolic links that point to directories?
--
Regards,
Peng
I'm wondering if there is a way to locate directory.
For example, file a.txt b.txt c.txt are in the directory 'a_dir'. When
I locate 'a_dir', all the three file shows up. I just want to show
'a_dir' rather the three files. Is there a way to do so?
a_dir/a.txt
a_dir/b.txt
a_dir/c.txt
--
Regards,
I don't find which option to use to search for broken symbolic links.
Could somebody let me know if there is such an option?
On Thu, Dec 31, 2009 at 9:23 PM, James Youngman wrote:
> On Thu, Dec 31, 2009 at 10:05 PM, Peng Yu wrote:
>> I know I can used wc -l to get the number of lines in a file. Could
>> somebody let me know how to search for files that have fewer than n
>> lines? (n is a nu
I know I can used wc -l to get the number of lines in a file. Could
somebody let me know how to search for files that have fewer than n
lines? (n is a number)
On Sat, Nov 28, 2009 at 4:12 AM, James Youngman wrote:
> On Sat, Nov 28, 2009 at 12:09 AM, Peng Yu wrote:
>> On Fri, Nov 27, 2009 at 2:54 PM, Eric Blake wrote:
>>> find -name '*.py' -print -o -name '*.sh' \
>>> -exec sh -c 'test ! -
On Fri, Nov 27, 2009 at 2:54 PM, Eric Blake wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> According to Peng Yu on 11/27/2009 8:38 AM:
>>> find . -name '*.sh' -o -name '*.py'
>>>
>>> ... do what you had in mind?
>>
On Fri, Nov 27, 2009 at 6:19 AM, James Youngman wrote:
> On Wed, Nov 25, 2009 at 3:56 AM, Peng Yu wrote:
>> I want to search for all '.py' files in a directory (recursively).
>> However, if there is a '.sh' file in the same directory where a '.py'
I want to search for all '.py' files in a directory (recursively).
However, if there is a '.sh' file in the same directory where a '.py'
is in, the '.sh' file rather than the '.py' file will be returned.
Would somebody let me know how to do so?
69 matches
Mail list logo