Most active commenters

    ←back to thread

    131 points tomschafer | 11 comments | | HN request time: 0.207s | source | bottom
    1. sigmonsays ◴[] No.42151991[source]
    We're losing the art of bash ``` find -type f -iname '*.go' | xargs -r -n1 sed -i 's,foo,foobar,g' ```
    replies(4): >>42153830 #>>42153991 #>>42154761 #>>42155854 #
    2. mh- ◴[] No.42153830[source]
    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.
    3. asicsp ◴[] No.42153991[source]
    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.
    replies(1): >>42154608 #
    4. theamk ◴[] No.42154608[source]
    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)

    replies(1): >>42155707 #
    5. lofaszvanitt ◴[] No.42154761[source]
    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

    replies(3): >>42154778 #>>42156856 #>>42161368 #
    6. KetoManx64 ◴[] No.42154778[source]
    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.
    7. asicsp ◴[] No.42155707{3}[source]
    `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.

    8. IshKebab ◴[] No.42155854[source]
    Yeah it's great! Difficult to remember Bash pipelines are being replaced with modern tools with good UX.
    replies(1): >>42206246 #
    9. fwip ◴[] No.42156856[source]
    You can save useful snippets in a file for later use.
    10. feelamee ◴[] No.42161368[source]
    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...

    11. sigmonsays ◴[] No.42206246[source]
    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.