Aritmetika v bash-i

Petr Janda janda na netbox.cz
Úterý Listopad 7 13:13:42 CET 2006


On Tue, Nov 07, 2006 at 11:39:43AM +0100, Vancl Miroslav (QRIS) wrote:
> Kolega me prakvapil (fungujicim) zapisem typu:
> 
> $x=$[$y+1]
> 
> tak jsem nelenil a zacal hledat v man bash... a nic jsem nenasel.
> Bud neumim hledat, nebo je to nejaka skryta vlastnost. Nemuzete me nekdo
> navest na popis, pripadne vysvetlit cim se $[ ... ] lisi od $(( ... )) ?
> 
> Diky
> 
> M. Vancl
> 

man bash (muj)

Arithmetic Expansion
       Arithmetic expansion allows the evaluation of an arithmetic expression
       and  the  substitution of the result.  The format for arithmetic expan-
       sion is:

              $((expression))

       The old format $[expression] is  deprecated  and  will  be removed  in
       upcoming versions of bash.

       The  expression  is  treated  as if it were within double quotes, but a
       double quote inside the parentheses  is  not  treated  specially.  All
       tokens in the expression undergo parameter expansion, string expansion,
       command substitution, and quote removal.  Arithmetic expansions may  be
       nested.

       The  evaluation  is performed according to the rules listed below under
       ARITHMETIC EVALUATION.  If expression is invalid, bash prints a message
       indicating failure and no substitution occurs.


Takze vlastne nijak, jen $[expression] prestane fungovat :-)
	
	S pozdravem 

				Petr Janda
--
email: /bin/sh -c 'A=netbox; B=janda; printf "%s@%s.cz\n" ${B} ${A}'



Další informace o konferenci Linux