Re: Bash Quirkiness

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

 



Am Mo, den 26.07.2004 schrieb Robert P. J. Day um 17:08:

> > 		a=`host $evil`
> > 		c=`expr "$a" : '.*\(\..*\.net\)'`
> > 		evilisp=${c/\./abuse\@}
> > 			if [ $evilisp > "0" ] ; then

> > Note the use of both ' and ` in the line with the "expr." I find that
> > they are not interchangeable. Assigning a variable to an 'expr' will not
> > work without the "`". In fact, I cut and pasted it from some web docs.
> > I'm not even really sure what character it is.

http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html

> it's short for "command substitution", which runs the command 
> contained with the ` quotes and produces what's printed to standard 
> output.  *very* different from the regular single quotes -- you *bet* 
> they're not interchangeable.
> 
> to avoid confusion, you can also identify command substitution with 
> the syntax $(... command ...), which i personally prefer, since it's 
> much clearer.  that is, you'd be better off writing:
> 
>       c=$(expr ... ')
> 
> at least, in my opinion.

$(foo) is the current notation and some day ` ` (backticks) will go away
from bash (by it's developers).

> rday

Alexander


-- 
Alexander Dalloz | Enger, Germany | GPG key 1024D/ED695653 1999-07-13
Fedora GNU/Linux Core 2 (Tettnang) kernel 2.6.6-1.435.2.3.ad.umlsmp 
Serendipity 17:18:07 up 2:24, 8 users, 1.92, 1.70, 1.46 

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux