2 ms·
All good advice. I was intentionally making a correctness/terseness tradeoff. :) > ...and arguments be expanded correctly with "$@" That assumes that your bas
by simoncion 11y ago
All good advice. I was intentionally making a correctness/terseness tradeoff. :)
> ...and arguments be expanded correctly with "$@"
That assumes that your bash is contained within a script, yes? It doesn't work for commands entered directly in a shell?
> ...unless you're using a really ancient version of bash, you shouldn't use backticks for command substitution.
I was -stupidly- unaware that backticks would nest. I always use $() when I want to nest command substitutions.
> "find ." and "find ./" are identical.
Oh, I know. I have the largely unjustifiable habit of always putting a path in a find invocation, as well as always spelling "the current directory" as ./
> > find | xargs
> Of course, this is always a nice option that bypasses the need for bash.
Don't forget -print0 and -0 if you expect to have to handle arguments that contain spaces! ;)
- pdkl95 11y ago> That assumes that your bash is contained within a script, yes? Or a function. (that is, anywhere the $1, $2, ... variables are available, as "$@" (must have the double-quotes!) just copies $1, $2, .. without changing the word splitting. > as well as always spelling "the current directory" as ./ That's actually a very good habit to be in a lot of other commands. It's unnecessary with find, but it's harmless either way.