Help! Unix (BSD) weirdness on redirect

…and I learn something new every day. Very clean to do it that way.

I was told not to use backquotes because your brain sees them as quotes and thus will sometimes leave out the (usually) requisite quotes surrounding them.

I went and looked at a script I had written, and indeed I had forgotten the double-quotes at least a couple of times. So now I use “$()”

Another reason is that you can nest $(), in the admittedly odd scenarios where you actually need to.

(It might be argued that nesting $() is bad style. This would carry weight if you were writing something you expected you’d have to maintain; for something you’ll use once on a command line, where it’ll be run and done before your mind can purge the context, this isn’t very relevant.)

Anyway, yes, I’m a fan of the various shell redirection characters and find cat clunky unless you’re actually concatenating more than one file. Otherwise, <, >, and >> are simply faster to write and no more complex to read.

I’ve always done this:


FOO=Hello
echo world | awk -vFOO=$FOO '{print FOO, $1}'