3.12. Backticks (`COMMAND`)

Command substitution

Commands within backticks generate command line text.

The output of commands within backticks can be used as arguments to another command or to load a variable.
   1 rm `cat filename`
   2 # "filename" contains a list of files to delete.
   3 
   4 textfile_listing=`ls *.txt`
   5 # Variable contains names of all *.txt files in current working directory.
   6 echo $textfile_listing
   7 #
   8 textfile_listing2=$(ls *.txt)
   9 echo $textfile_listing
  10 # Also works.

Note

Using backticks for command substitution has been superseded by the $(COMMAND) form.

Arithmetic expansion (commonly used with expr)

   1 z=`expr $z + 3`
Note that this particular use of backticks has been superseded by double parentheses $((...)) or the very convenient let construction.
   1 z=$(($z+3))
   2 # $((EXPRESSION)) is arithmetic expansion.
   3 # Not to be confused with command substitution.
   4 
   5 let z=z+3
   6 let "z += 3"  #If quotes, then spaces and special operators allowed.
All these are equivalent. You may use whichever one "rings your chimes".