Common Unix Concepts and Commands, part 2 ----------------------------------------- Regular expressions - powerful pattern-matching sublanguage - akin to filename patterns, but more powerful - used by a number of commands, e.g. grep, sed; emacs uses a version - basic regexp rules: - matches exactly itself, unless special: . - matches any one character [...] - matches any one character in set [^...] - matches any one character *not* in set ^ - matches beginning of line $ - matches end of line \ - matches , even if special - sequence: matches followed by \| - alternation: matches or * - iteration: matches 0 or more occurrences of \(\) - grouping: matches - extended regexps allow more things; see man pages - vs. filename patterns: ? in filename pattern => . in regexp * in filename pattern => .* in regexp {,} in filename pattern => \(\|\) in regexp Grep: command to search lines in files that match regular expressions grep ... - print out lines of ... that match grep -v ...- print out lines of ... that *don't* match Sed: command to edit lines in files, e.g. that match regular expressions sed -e ... - execute sed command on s many possible s; one important one: s///g - replace all occurrences matching with