[TriLUG] HERE document question

Kevin Hunter hunteke at earlham.edu
Tue Jul 27 22:56:35 EDT 2010


At 3:41pm -0600 Mon, 26 Jul 2010, Joseph Mack NA3T wrote:
> On Sun, 25 Jul 2010, Kevin Hunter wrote:
>> 1. Don't use backticks for subshell work.
>
> Thanks for your help.
>
> I didn't know about this, but then it's been a while since I looked for
> anything new in bash. I did find an example of nested backticks in case
> anyone needs to extend the idiom :-)
>
> word_count=` wc -w \`echo * | awk '{print $8}'\`

To finish this thought, yes, you can nest backticks this way.  But 
consider double, triple, or quadruple nesting.  I've never had the 
pleasure or need to write such constructs, but dear God have I read them:

$ echo `echo \`echo \\\`echo \\\\\\\`uname -mo\\\\\\\`\\\`\``
x86_64 GNU/Linux

I kid you not that I have seen this construct before.  As opposed to
echo $(echo $(echo $(echo $(uname -mo))))

Kevin



More information about the TriLUG mailing list