4 ms·
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
by Dibby053 2mo ago
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.
- wongarsu 2mo agoI 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
- giov4 2mo agoI 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.
- jimmaswell 2mo ago> Find works, but the syntax is arcane. fd is a lifesaver: https://github.com/sharkdp/fd https://github.com/sharkdp/fd
- Grimeton 2mo agoNewer finds have a -delete option. Dunno if that's standard or some GNU addition, but it's there.
- IsTom 2mo agoTo be pendantic ls -- **/*.sh Otherwise it will fail if you've got a file named e.g. --help
- westurner 2mo agoBut `ls -print0` is not an option; set -x mkdir test; cd "$_" touch "test "$'\n'"12.txt" ls for name in `ls`; do echo "$name"; done find find . -exec echo {} \; find . -print0 find . -print0 | xargs -n 1 -0 echo # find . -print0 | el -0 -v -x echo find . -print0 | el -0 -v -x echo "{0} #" find . -print0 | el -0 -v -x echo '"{0}" #' find . -print0 | el -0 -x sh -x -c 'echo "{0} #"' Though, I just realized that this doesn't work yet either: find . -print0 | el -0 -x -- sh -c 'set -x: echo "{0} #"' westurner/dotfiles/scripts/el: "edit lines" https://github.com/westurner/dotfiles/blob/master/scripts/el.py https://github.com/westurner/dotfiles/blob/master/scripts/el... `el -v/--verbose` is useful because it prints each input; though, I might not have written `el` if I had been aware of `xargs -n/--max-args=1`
- tolciho 2mo agofor name in `ls`; do echo "$name"; done is an unportable and expensive way to write for name in *; do printf '%s\n' "$name"; done but you could also just printf '%s\n' *
- js2 2mo agoI thought I knew every nook and cranny of bash, but somehow never noticed the globstar option added in bash 4.0. https://www.linuxjournal.com/content/globstar-new-bash-globbing-option https://www.linuxjournal.com/content/globstar-new-bash-globb... https://www.gnu.org/software/bash/manual/bash.html#Pattern-Matching https://www.gnu.org/software/bash/manual/bash.html#Pattern-M...