Hacker News new | past | comments | ask | show | jobs | submit login

We're losing the art of bash ``` find -type f -iname '*.go' | xargs -r -n1 sed -i 's,foo,foobar,g' ```





Why use `xargs` instead of `-exec`? And if you do need `xargs` (for example, for parallel processing with `-P`), it is recommended to use `-print0` with `find` and `-0` with `xargs` to avoid issues due to filenames.

xargs passes many inputs to one script invocation, so even with a single thread there is often a dramatic speedup.

(and agree re -print0/-0, it's absolutely essential)


`find` can do that as well with `{} +` (at least, the `GNU` implementation and it'll automatically add more invocations if there are just way too many files).

In any case, OP was using `-n1` which means one file per invocation.


Something that frequently trips me up, mostly when helping colleagues, is the arguments to both find and xargs differ substantially between GNU and the FreeBSD-derived ones that ship on macOS.

The problem is... if you use these on rare occasions it gets frustrating, because you have to read the manual or google everything or ask the llm again and again.

noone can remember these abbreviations


https://atuin.sh/ is such a huge productivity booster in these scenarios. I remember that I used find + xargs command sometime in the last 6 months on of my computers and with Atuin I can quickly find it and then slightly modify it to fit my current need.

You can save useful snippets in a file for later use.

yes, but...

noone except your shell! Fish is perfect and very very often can guess what I want using pwd, file existence, current prompt, etc...


Yeah it's great! Difficult to remember Bash pipelines are being replaced with modern tools with good UX.

I disagree, They are not difficult to remember.

you'll never build good UX and a powerful tool. You're either a master of your tool or you're not.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: