6.3 Command Substitution


11. More on Command Substitution:
This facility tells the shell to execute the enclosed unix command and insert
the standard output from the command in the place where the back quotes are on
that command line.

12. For examples: 
$ echo "The date and time are: `date`"
The date and time are: Thu May 22 06:30:14 PDT 2001	
$ curdir="`pwd`"
$ cd /
$ cd $curdir
$ echo "You have `ls | wc -l` files in your directory."
You have 7 files in your directory.
$ filelist=`ls`
$ echo $filelist

$ echo "$filelist"
$ namelist=`cat names`
echo "$namelist"
Crockett
Boone
Oakley
James
Hickok

$ ls
data.good
even.better
tempo
waste
$ echo rm `ls | grep -v '\.'`
$ rm `ls | grep -v '\.'`
$ ls
data.good
even.better

Questions? Robert Katz: rkatz@ned.highline.edu
Last Update July 30, 2002