* Tony Baldwin wrote on 2012-01-21 at 12:15 (-0500):

> Why use $(command) instead of `command`?
> Generally, I've always used $(command), but see scripts all
> over using `command`, and wondered if there were advantages of
> one over the other.  It seems they give the same result, no?

Some do, some don't :-)  See some curious examples on
http://tldp.org/LDP/abs/html/commandsub.html
For short, I think you should use $(...) and try to avoid `...`.
Also keep in mind that in Debian /bin/sh -> dash

----------test1.sh----------
#!/bin/sh
set -xv
echo `echo \\`
echo $(echo \\)
----------------------------

$ ./test1.sh        <-------- same output as  dash ./test1.sh
echo `echo \\`
+ echo \
+ echo \
\                   <-------- Watch this...
echo $(echo \\)
+ echo \
+ echo \
\

$ bash ./test1.sh
echo `echo \\`
echo \
++ echo
+ echo
                    <-------- ...and this!
echo $(echo \\)
echo \\)
echo \\
++ echo '\'
+ echo '\'
\

Mathias


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20120121180536.gb15...@gmx.org

Reply via email to