News for hackers. Stuff that matters.
Re:Safe ways to do things in bash by thisacctforreal on Tuesday May 15, 2018 @04:44AM (#17072536)
$( allows any syntax until a non-escaped ). It's Command Substitution[1], and they run in "subshells".

    echo hello "$(
        echo hello \
        | sed 's,hello,world,g'
    )"
[ is an actual binary file that gets invoked, called test. You can "man [" or "man test" to learn about all of its uses.

I use [ exclusively, but with && and ||, instead of -a and -o respectfully.

e.g. [ -e "$file" ] && [ -w "$file" ] instead of [ -e "$file" -a -w "$file" ].

[1] http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu...

There are no comments on this comment yet.