CS 279 - Week 10 Lecture 1 - 10-23-12

*   when you use =~ operator within [[ ]] with
    a regular expression,
    IF that RE has parenthesized subexpressions,
    then you can ACCESS those from the
    BASH_REMATCH array variable.

    *   ${BASH_REMATCH[0]} - contains the matched
        substring.
    *   then ${BASH_REMATCH[1]} contains the 
        match for the 1st subexpression,
	and [2] for the 2nd subexpression, ...

*   see rematch-play.sh
    and clicker-rematch.sh.

gzip and gunzip
---------------
*   see pp. 140-143 in the course text for more
    on these.

*   gzip and gunzip
    *   gzip compresses one or more files,
        gunzip uncompresses one or more files.

    *   uses Lempel-Ziv compression.

    *   TYPICAL compression rates of 60-70%
        for natural language text,
	computer source code files.
        (NOT all files compress well!!)

*   SIMPLEST use:
    *   gzip filename
        ...and the result will be filename's
	   removal, and a new hopefully-compressed
	   file filename.gz in its place.

    *   gunzip filename.gz
        ...and result will be 
           hopefully-uncompressed file filename
	   (and the .gz version is removed).

*  a FEW of the potential options:
   *   note that if NO filenames are given,
       compressed stdin to stdout (so
       COULD use this in a pipe!).

   *   -c option keeps the original file unchanged.

   *   -S desired-suffix uses that suffix instead
       of .gz.

    *   -n: for compressing, means DON'T save
            the original name and time stamp
	    for expanding, don't restore the 
	    original name and timestamp, just
	    remove the .gz.

    *   -N: for compressing, save the original
            pathname and timestamp (default);
	    for expanding, restore the original
	    pathname and timestamp.

    *   -r traverses the directory structure
           recursively.

    *   -v (verbose) display the name of the
           file compressed or expanded and 
	   the % reduction.

tar
---
*   much more on this on pp. 151-154.
*   archive: a collection of files in which
    each file is labeled with information
    about its origin.
*   several main purposes:
    *   to have a convenient package.
    *   to have a BACKUP copy.
    *   to have a package that's more shareable/
        transportable.

*   tar - stands for tape archive,
    but it doesn't have to involve magnetic
    tape.
    *   tar cvf desired-archive-name.tar original-directory
        create archive desired-archive-name.tar
	from original-directory.

        c option needed to specify creation of a tar archive.
        v option is optional, verbose, means output what's
	    being done. Fun fact: the verbose output seems to be not
	    to standard output, but to standard error!
        f option means you specify the name of the archive file
	    to be created (that .tar filename following the cvf).

    *   tar xvf desired-archive-name.tar
        extract files from desired-archive-name.tar
        and restore them
        (extract back into directory form).

        x option needed to specify that you want to extract files
            from the archive.
        v option is optional, verbose, means output what's
	    being done. 
        f option means you specify the name of the archive file
	    to be extracted from (that .tar filename following the
	    xvf).
        
other fun options:
   r   - append the files to the end of the archive.
   t   - list the contents of the archive.
   u   - update the archive by only adding files
         not yet there or modified since the
	 last archive write.

   w   - wait for confirmation of each action.