Difference between revisions of "Bash operators"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
Line 6: Line 6:
  
 
  for i in $(seq 1 1 100); do echo $i; done
 
  for i in $(seq 1 1 100); do echo $i; done
 +
 +
= $(()) =
 +
The operator $(()) in the bash shell is replaced by the arithmetic result of the expression enclosed in the parentheses.
 +
 +
Examples:
 +
# echo $((2*2))
 +
4

Revision as of 13:58, 30 March 2009

$()

The operator $() in the bash shell is replaced by the output of the command enclosed in the parentheses. It is equivalent to backticks (``), but can be cascaded more easily.

Examples:

rpm -ql $(rpm -qa)
for i in $(seq 1 1 100); do echo $i; done

$(())

The operator $(()) in the bash shell is replaced by the arithmetic result of the expression enclosed in the parentheses.

Examples:

# echo $((2*2))
4