shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: qual diferença entre `cmd` e $(cmd)?


From: Mauricio
Subject: Re: qual diferença entre `cmd` e $(cmd)?
Date: Wed, 15 Mar 2006 07:57:44 +0000
User-agent: Mozilla Thunderbird 1.0.6 (X11/20050716)

Conforme está escrito no último parágrafo, está aí a diferença:

#!/bin/bash

teste='diferença'
var=`echo \$teste`
var2=`echo \\$teste`
var3=$(echo \$teste)
echo Var="$var"
echo Var2="$var2"
echo Var3="$var3"

Resultados:

Var=diferença
Var2=$teste
Var3=$teste

Abraço a todos,
Ricio

Tiago Barcellos Peczenyj wrote:
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]



---------------------------------------------------------------------
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

Links do Yahoo! Grupos








        

        
                
___________________________________ Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it


reply via email to

[Prev in Thread] Current Thread [Next in Thread]