Download   Online Shop   Red Hat Network
Home  |  Products & Services  |  Support  |  Training  |  Partners  |  Documentation   
Red Hat Documentation

Overview | HOWTOs | mini-HOWTOs | FAQs | Linux Man-Pages

Backticks (`COMMAND`)

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.
rm `cat filename`
# "filename" contains a list of files to delete.
textfile_listing=`ls *.txt`
# Variable contains names of all *.txt files in current working directory.
echo $textfile_listing
#
textfile_listing2=$(ls *.txt)
echo $textfile_listing
# Also works.

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

Arithmetic expansion (commonly used with expr)

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

 

 
 
Search for:  on    Powered by Google
Products & Services   :   Download   :   Support   :   Training   :   Partners & Programs
© 2000 Red Hat, Inc. All right reserved.       About Red Hat   :   Legal statement   :   Privacy statement   :   Y2K statement   :   Contact Red Hat