CS 279 - Week 6 Lab - 9-26-12

*  command substitution

   when you put a command within backquote 
   characters

   echo "Present loc is `pwd`"

   ...then that backquoted expression is replaced
   by its results

   you can get the same behavior with $(...)

   echo "Present loc is $(pwd)"
   
*   this is nice in shell scripts!

*   a few additional commands for backquote
    playing:

    expr - evaluates an expression, sending
           the result to standard output

    expr 3 + 5

    basename - grabs the base/basename of a pathname
               (the "last" part, the local filename)
    dirname  - grabs everything but the base/basename
               (the directory of the base)

*   bash has two styles of for loops --
    one is to iterate over a list
    and one is a C-style-ish (traditional-ish) for loop

    for <varname> in <list>
    do
        command1 
        command2
	...
    done

how about the other for-loop style?

for (( expr1; expr2; expr3 ))
do
    command1
    command2
    ...
done

*   fun fact:

    grep w/ a pattern and a list of files
    returns the file name, colon, and line containing
    that pattern

    grep -l pattern files
    ...returns JUST the names of files with that pattern

    ...this would work nicely for a loop with command
       substitution