Week 5 Regular Expressions + An expression needs to be evaluated and describes a result + A regular expression is a shorthand for abbreviating patterns of text. + Regular expressions are set of rules, used to specify one or more items in a single character string (a sequence of characters) + A regular expression describes a pattern , a particular sequence of characters. It does not necessarily specify a single exact sequence + A regular expression is a way of describing a pattern of characters to a program so that it can either display or modify the occurrences of that pattern. + Regular expressions are a very powerful tool for searching and processing text + Regular expressions are case sensitive + A regular expression is made up of the two elements o a value expressed as a literal or a variable o An operator + Regular expressions are used to write simple to complex descriptions of patterns Cmds that use RG grep(1), egrep(1), sed(1), awk(1), perl(1) and shell. Shell Metacharacters ? * [] ? means match any single character [] means match any single character specified as a character or as a range inside the sq. brackets * means match all I/O redirection. ---------------- ps -ef > ps.out cat /etc/passwd >> cat.out ps -ef cat < /etc/group ps -ef > ps.out 2>ps.err ps -ef > ps.out 2>&1 ps -ef 2>ps.err 1>&2 Exec ---- exec < /etc/passwd exec > /tmp/output exec 3<>/dev/console exec 4/tmp/opt ps -ef > &5 ls >&5 cat < &4