Bash Quirkiness

Alexander Dalloz alexander.dalloz at uni-bielefeld.de
Mon Jul 26 15:20:03 UTC 2004


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 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://listman.redhat.com/archives/fedora-list/attachments/20040726/0ab4ea79/attachment-0001.sig>


More information about the fedora-list mailing list