CS 279 - Week 6 Lecture 2 - 9-29-12
* local variables -- I think section 2.13 of the
course text doesn't completely apply to bash...
* see examples in varplay.sh and clicker1.sh
* above were LOCAL variables -- what if you'd like
to make your own ENVIRONMENT variables?
...precede the creation of the variable with
the command export
export DOG="caesar"
* Initialization files
* a UNIX program can have these..
* bash has several!
* for bash,
.bash_profile is executed for login shells
.bashrc is executed for interactive non-login
shells
REGULAR EXPRESSIONS
--------------------
* regular expression - RE - defines a pattern of
text to be matched
...expected by a number of UNIX utilities, such
as grep, sed, and more
* 2 kinds of REs in UNIX:
basic regular expressions: BRE
extended regular expressions: ERE
BRE - understood by older UNIX programs (grep,
ed, sed)
ERE - a generalization of BRE recognized by
egrep (same as grep -E)
BREs
----
* a "regular" character in a BRE matches that
character in the text
grep oink * # found lines in the files in the cwd
# containing oink anywhere in them
* these are special characters in BRE:
. matches any single character
* if this follows a single character,
matches 0 or more occurrences of that char
a pattern that matches a SET of characters
followed by a * matches ZERO or MORE characters
FROM THAT SET