# Help!  Unix (BSD) weirdness on redirect

**URL:** <https://boards.straightdope.com/t/help-unix-bsd-weirdness-on-redirect/710489>\
**Category:** Factual Questions\
**Created:** [January 21, 2015, 4:18pm UTC](https://boards.straightdope.com/t/help-unix-bsd-weirdness-on-redirect/710489 "2015-01-21T16:18:39Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![Belrix](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Belrix](https://boards.straightdope.com/u/Belrix)\
**Post date:** [January 22, 2015, 4:47am UTC](https://boards.straightdope.com/t/help-unix-bsd-weirdness-on-redirect/710489/21 "2015-01-22T04:47:30Z")

</div>

> [@Pasta](#):
>
> export FOO=“Hello”  
> echo world | awk ‘{print ENVIRON[“FOO”],$1}’

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

---

<div class="post-metadata">

**Author:** ![BigT](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/bigt/32/12044_2.png) [@BigT](https://boards.straightdope.com/u/BigT)\
**Post date:** [January 22, 2015, 5:17am UTC](https://boards.straightdope.com/t/help-unix-bsd-weirdness-on-redirect/710489/22 "2015-01-22T05:17:30Z")

</div>

> [@Belrix](#):
>
> …its funny to see different shell programming styles. I always insist on single quotes around awk statements, changes how we escape to external variables. I always back-quote to run a external command while **friedo** does a $( cmd ).

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 “$()”

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [January 22, 2015, 7:55am UTC](https://boards.straightdope.com/t/help-unix-bsd-weirdness-on-redirect/710489/23 "2015-01-22T07:55:29Z")

</div>

> [@BigT](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Rysto](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@Rysto](https://boards.straightdope.com/u/Rysto)\
**Post date:** [January 22, 2015, 1:55pm UTC](https://boards.straightdope.com/t/help-unix-bsd-weirdness-on-redirect/710489/24 "2015-01-22T13:55:02Z")

</div>

> [@Pasta](#):
>
> I’ve always used this construction:
> 
> ```auto
> 
> export FOO="Hello"
> echo world | awk '{print ENVIRON["FOO"],$1}'
> 
> ```

I’ve always done this:

```auto

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

```

[Previous page](https://boards.straightdope.com/t/help-unix-bsd-weirdness-on-redirect/710489.md?page=1)
