GithubHelp home page GithubHelp logo

Comments (3)

koalaman avatar koalaman commented on June 24, 2024

You're quite right: it should not be complaining when using -print0. I'll fix this shortly.

You did ignore its advice and used "-exec {} ;" instead of "-exec {} +" though, which is why your alternative is slower :P

from shellcheck.

arth1 avatar arth1 commented on June 24, 2024

Thanks for fixing!

Actually, even with exec {} +, find is notably slower than xargs. The main reason is that it blocks the find process while doing a block of exec.

$ time find . -type f -exec ls -d >/dev/null {} +

real 0m3.790s
user 0m2.368s
sys 0m1.346s
$ time find . -type f -exec ls -d >/dev/null {} +

real 0m3.779s
user 0m2.404s
sys 0m1.295s
$ time find . -type f -exec ls -d >/dev/null {} +

real 0m3.806s
user 0m2.412s
sys 0m1.315s
$ time find . -type f -print0 | xargs -0 ls -d >/dev/null

real 0m3.122s
user 0m2.644s
sys 0m1.372s
$ time find . -type f -print0 | xargs -0 ls -d >/dev/null

real 0m3.157s
user 0m2.628s
sys 0m1.343s
$ time find . -type f -print0 | xargs -0 ls -d >/dev/null

real 0m3.185s
user 0m2.633s
sys 0m1.387s
$ find . -type f | wc -l
175730

... and never mind that you can also pass -P NNN to xargs :P

$ time find . -type f -print0 | xargs -0 -P 8 ls -d >/dev/null

real 0m0.810s
user 0m3.503s
sys 0m1.585s

from shellcheck.

koalaman avatar koalaman commented on June 24, 2024

Shellcheck no longer warns about piping find to xargs -0

from shellcheck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.