Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page modification request: find #15107

Open
zmajeed opened this issue Dec 9, 2024 · 4 comments · May be fixed by #15108
Open

Page modification request: find #15107

zmajeed opened this issue Dec 9, 2024 · 4 comments · May be fixed by #15108
Labels
help wanted You can help make tldr-pages better! page edit Changes to an existing page(s).

Comments

@zmajeed
Copy link

zmajeed commented Dec 9, 2024

Command description

Two find examples are wrong or misleading

  1. The use of globstar ** below is misleading
  • Find files matching multiple path/name patterns:
    find {{root_path}} -path '{{**/path/**/*.ext}}' -or -name '{{*pattern*}}'

find does not support globstar - it uses fnmatch() for glob patterns which doesn't recognize globstar syntax - find does not set the FNM_PATHNAME flag for fnmatch() - this means a single star * matches anything including slash in paths and two consecutive stars are effectively redundant

The example should be

  • Find files matching multiple path/name patterns:
    find {{root_path}} -path '{{*/path/*/*.ext}}' -or -name '{{*pattern*}}'
  1. The following example has wrong syntax - it uses pipe | instead of comma , to match multiple types - also pipe is not escaped for the shell which interprets the command as a pipeline and would be an error or cause unexpected results
  • Find empty files (0 byte) or directories and delete them verbosely:
    find {{root_path}} -type {{f|d}} -empty -delete -print

From https://manned.org/man/find

-type c
              File is of type c:

              To search for more than one type at once, you can supply the
              combined list of type letters separated by a comma `,' (GNU
              extension).

The example should be

  • Find empty files (0 byte) or directories and delete them verbosely:
    find {{root_path}} -type '{{f,d}}' -empty -delete -print

Command details

No response

Documentation

https://manned.org/man/find

Platform

Linux

VCS repository link (e.g. GitHub, GitLab)

https://git.savannah.gnu.org/cgit/findutils.git

Additional information

No response

@zmajeed zmajeed added help wanted You can help make tldr-pages better! page edit Changes to an existing page(s). labels Dec 9, 2024
@zmajeed zmajeed linked a pull request Dec 9, 2024 that will close this issue
6 tasks
@gutjuri
Copy link
Member

gutjuri commented Dec 11, 2024

The following example has wrong syntax - it uses pipe | instead of comma , to match multiple types - also pipe is not escaped for the shell which interprets the command as a pipeline and would be an error or cause unexpected results

The | is tldr-syntax (see styleguide). It is used when there is a fixed number of possible values that can be used in an argument.

@zmajeed
Copy link
Author

zmajeed commented Dec 11, 2024

Not sure I follow ... Are you saying the find commandline example is not meant to be run as-is?

@zmajeed
Copy link
Author

zmajeed commented Dec 11, 2024

If the pipe is meant to say -type only takes f or d then that's misleading because it can take a few other letters - and with the comma , separator it can take multiple letters at the same time

@gutjuri
Copy link
Member

gutjuri commented Dec 11, 2024

Not sure I follow ... Are you saying the find commandline example is not meant to be run as-is?

No, the examples are generally meant to be modified before running. E.g. we have this example

`7z a -t{{7z|bzip2|gzip|lzip|tar|zip}} {{path/to/archive}} {{path/to/file_or_directory}}`
which includes some possible options that can be passed to 7zip.

However, I think that you are right that in this particular case, the example is misleading, especially with the wording of the description. So yes, we should probably change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted You can help make tldr-pages better! page edit Changes to an existing page(s).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants