[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] qual diferença entre `cmd` e $(cmd)?
From: |
Tiago Barcellos Peczenyj |
Subject: |
Re: [shell-script] qual diferença entre `cmd` e $(cmd)? |
Date: |
Tue, 14 Mar 2006 14:40:29 -0300 |
Direto do Man Bash, aparentemente são duas formas equivalentes. Entretanto a
forma $( comando ) é mais clara e menos suceptivel a erros de leitura por
parte humana (isto eh, a gente não confunde com aspas simples).
Command Substitution
Command substitution allows the output of a command to replace the com-
mand name. There are two forms:
$(command)
or
`command`
Bash performs the expansion by executing command and replacing the com-
mand substitution with the standard output of the command, with any
trailing newlines deleted. Embedded newlines are not deleted, but they
may be removed during word splitting. The command substitution $(cat
file) can be replaced by the equivalent but faster $(< file).
When the old-style backquote form of substitution is used, backslash
retains its literal meaning except when followed by $, `, or \. The
first backquote not preceded by a backslash terminates the command sub-
stitution. When using the $(command) form, all characters between the
parentheses make up the command; none are treated specially.
On 3/14/06, Jorge Pereira <address@hidden> wrote:
>
> qual diferença entre `cmd` e $(cmd)?
>
> --
> Regards,
> Jorge Pereira, From: Olinda/Pe/Brazil
> Home: http://www.jorgepereira.com.br/
> E-mail: address@hidden, address@hidden
> Mobile: +55 (81) 8833-2484
> "Se você ama alguma coisa, liberte-a;
> Se ela não voltar a ti, cace-a e mate-a."
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
> ---------------------------------------------------------------------
> Esta lista não admite a abordagem de outras liguagens de programação, como
> perl, C etc. Quem insistir em não seguir esta regra será moderado sem prévio
> aviso.
> ---------------------------------------------------------------------
> Sair da lista: address@hidden
> ---------------------------------------------------------------------
> Esta lista é moderada de acordo com o previsto em
> http://www.listas-discussao.cjb.net
> ---------------------------------------------------------------------
> Servidor Newsgroup da lista: news.gmane.org
> Grupo: gmane.org.user-groups.programming.shell.brazil
>
>
>
>
> *Yahoo! Grupos, um serviço oferecido por:* PUBLICIDADE
> <http://br.ard.yahoo.com/SIG=12fm7hqf1/M=396553.7942726.8955931.2369893/D=brclubs/S=2137111254:HM/Y=BR/EXP=1142364997/A=3365488/R=2/id=noscript/SIG=154hjlk1t/*http://lt.dell.com/lt/lt.aspx?CID=11593&LID=319636&DGC=BA&DGSeg=DHS&DURL=http://www1.la.dell.com/content/products/category.aspx/desktops?c%3dbr%26l%3dpt%26s%3ddhs>
> ------------------------------
> *Links do Yahoo! Grupos*
>
> - Para visitar o site do seu grupo na web, acesse:
> http://br.groups.yahoo.com/group/shell-script/
>
> - Para sair deste grupo, envie um e-mail para:
> address@hidden<address@hidden?subject=Unsubscribe>
>
> - O uso que você faz do Yahoo! Grupos está sujeito aos Termos do
> Serviço do Yahoo! <http://br.yahoo.com/info/utos.html>.
>
>
--
Tiago B Peczenyj
Linux User #405772
# cd /pub
# more beer
[As partes desta mensagem que não continham texto foram removidas]