Backtick versus $()

Andres Perera andres.p at zoho.com
Mon Feb 21 02:49:50 UTC 2011


On Sun, Feb 20, 2011 at 1:42 PM, David Demelier
<demelier.david at gmail.com> wrote:
>
> I'd prefere $() rather than ``. It's more powerful, for example you can
> write a multiple $() but not `` see :

that's not true

for i in bash dash mksh; do
echo $i:
$i <<'!'
echo `echo 1\`echo 2\\\`echo 3\\\\\\\`echo 4\\\\\\\`\\\`\``
!
done

bash:
1234
dash:
1234
mksh:
1234

>
> markand at Abricot ~ $ echo $(basename $(which dmesg))
> dmesg
>
> markand at Abricot ~ $ echo `basename `which dmesg``
> usage: basename string [suffix]
>       basename [-a] [-s suffix] string [...]
> which dmesg
>
> Of course the example code is useless but shows the limitations of ``.
> Nowadays all shells supports $() so I advise you to use it :).

no, not all shells support $()

>
> Cheers,
>
> --
> David Demelier
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
>


More information about the freebsd-questions mailing list