Live data from Hacker News

I wrote an bash enumerator because I was sick of xargs

numerlab.org

131–140 of 202 posts

Re: I wrote an bash enumerator because I was sick of xargs

#131

Earlier quoted context omitted.

Some of these are wrong, as standard shell globs don't traverse directories. For instance the first example should be: ls **/*.sh I think that would work in Bash just as well as using find. But yeah, even in POSIX it feels redundant when we already have find, seq, grep and whatnot.

I frequently have cases where `ls **/*.png` fails because the argument list is too long. Just happened yesterday with an rm I wanted to run. Find works, but the syntax is arcane. Not bad , but unlike any other common cli tool, which makes it more difficult to remember if you haven't needed it in a while

I agree and I usually ended-up combining find reliability with other commands to obtain what I needed without big issues or too much looping syntax effort.

Regarding remembering the find syntax I think its being arcane is what it made for me more easy to remember :) I now have a unique brain area dedicated to remember only that.

Re: I wrote an bash enumerator because I was sick of xargs

#133
I was also sick of bash ways of dealing with lots of data, spaces in file names, etc, so I created csv-nix-tools: https://github.com/mslusarz/csv-nix-tools

E.g. removing all temporary files without the need to deal with spaces, glob limits, or silly find syntax:

csv-ls -R -c full_path . | csv-grep -c full_path -e '~$' | csv-exec -- rm -f %full_path

Re: I wrote an bash enumerator because I was sick of xargs

#134
post #118

I lol'd, but do you think this is valid? https://github.com/wallach-game/bashumerate/pull/1/files to me looks like a right solution, even if I was also tired of writing for loops by hand usually

Some of these are wrong, as standard shell globs don't traverse directories. For instance the first example should be: ls **/*.sh I think that would work in Bash just as well as using find. But yeah, even in POSIX it feels redundant when we already have find, seq, grep and whatnot.

To be pendantic

    ls -- **/*.sh
Otherwise it will fail if you've got a file named e.g. --help

Re: I wrote an bash enumerator because I was sick of xargs

#135
post #122

Earlier quoted context omitted.

On a second thought I think that the effort in trying to find a shell uncomfortability problem and trying to solve it with a "wrapped workaround" still represents positive effort and should be supported and fostered without jumping directly in 90's like rtfm mode. especially in the case of a younger profile, learning and putting dev effort, even if vibed or redundant, its still effort and a learning activity! https:/…

It's possible the tool is useless and a consequence of not reading the manual, but it could just be the tool is nice but the examples are too simplistic. In any case, toxicity aside, publishing a command line project and having someone dismiss the examples with shell oneliners is also a valuable lesson, and I don't think it will make him a worse developer.

that's what I also thought when I saw the pull request, that it could be a useful lecture.

But again the usefulness of the final tool should not compromise appreciation of effort and learning.

Unless the tool targets, claims or pretends to be the best, final and universal solution to such problem.

I believe it isn't, I will still fall back to my bash memories, I will not need, install and use this tool, I will not need, install or use custom shells. The effort wasted in re-aligning my brain to a tool change would superseed instantly the few second effort needed to reach the needed bash one-liner.

Also, didn't you also feel good and amazed when completing a very long and nested working one-liner? wasn't that orgasmic? :D

Re: I wrote an bash enumerator because I was sick of xargs

#136
post #7

Not sure I see the point of this. Remembering a bunch of options on one tool is no better than a bunch of tools/constructs? Especially if the latter are useful elsewhere. And it can't be used for scripts unless you start shipping it alongside, which… nah. Just go with foo | while read X; do bar "$X"; done

Yes, I think the author is just showing their ignorance, not actually doing anything about that ignorance, and re-inventing the wheel:

    $ find /path -name "*.pdf" -print0 | xargs -0 -I {} echo "Processing: {}" # handles paths properly, obviates the need to write anything new whatsoever
Seriously kids, learn your tools and check yourself before you wreck yourselves writing tools that really, really don't need to be written.

Re: I wrote an bash enumerator because I was sick of xargs

#138

In this thread: bash experts with arcane knowledge, unintentionally demonstrating how awful bash is. The obvious solution would be to use something more sane, like PowerShell or nushell, but instead old experts will always defend the skills they have honed for years, while criticizing anything that's different.

I'm sure it's essentially a familiarity thing, but PowerShell and nushell is way too much typing for me.

Re: I wrote an bash enumerator because I was sick of xargs

#139
post #78

Earlier quoted context omitted.

Depending on the actual command, this can be far slower and less efficient than xargs. You're creating a separate process for each invocation of bar when a lot of commands will take many targets for a single invocation. Try this with find and grep vs xargs. There's a big difference.

3 reasons against that: * in a lot of cases the performance just doesn't matter * xargs gets you the spaces in filenames landmine * some commands don't even support multiple target filename arguments For scripts in long term use, yeah, sure, figure out xargs maybe. Any other situation with a "| while read" solution, especially on an interactive session, is an oddball and simplicity wins.

>* xargs gets you the spaces in filenames landmine

Ignorance of xargs gets you the landmine.

Understanding of xargs, helps you complete the mission without blowing off limbs.

    $ find . -name "Some Files With Spaces*.txt" -print0 | xargs -0 -I {} echo "Processing: {}"  # landmine avoided

Re: I wrote an bash enumerator because I was sick of xargs

#140

In this thread: bash experts with arcane knowledge, unintentionally demonstrating how awful bash is. The obvious solution would be to use something more sane, like PowerShell or nushell, but instead old experts will always defend the skills they have honed for years, while criticizing anything that's different.

This is a sleeper option, but 'xonsh' as a Python superset is a very pleasant experience, especially when you just don't feel like learning another bespoke language for the complex stuff.

I once had to scrape the output out of something hacked together by a grad student 10 years before me, scrape yet another hacked together application, do some fancy numerics, and then plonk it into a database. I did it without tears!

Post reply on HN