home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  

sed & awk

sed & awkSearch this book
Previous: 3.2 A Line-Up of Characters Chapter 3
Understanding Regular Expression Syntax
Next: 4. Writing sed Scripts

3.3 I Never Metacharacter I Didn't Like

Table 3.4 lists interesting examples of regular expressions, many of which have been described in this chapter.

Table 3.4: Useful Regular Expressions
Item Regular Expression
Postal Abbreviation for State  [A-Z][A-Z]
City, State ^.*, [A-Z][A-Z]
City, State, Zip (POSIX egrep ) ^.*, [A-Z][A-Z] [0-9]{5}(-[0-9]{4})?
Month, Day, Year [A-Z][a-z]\{3,9\} [0-9]\{1,2\}, [0-9]\{4\}
U.S. Social Security Number [0-9]\{3\}-[0-9]\{2\}-[0-9]\{4\}
North-American Local Telephone [0-9]\{3\}-[0-9]\{4\}
Formatted Dollar Amounts \$[ 0-9]*\.[0-9][0-9]
troff In-line Font Requests \\f[(BIRP]C*[BW]*
troff Requests ^\.[a-z]\{2\}
troff Macros ^\.[A-Z12].
troff Macro with arguments ^\.[A-Z12]. ".*"
HTML In-line Codes <[^>]*>
Ventura Publisher Style Codes ^@.* = .*
Match blank lines ^$
Match entire line ^.*$
Match one or more spaces   *

Previous: 3.2 A Line-Up of Characters sed & awk Next: 4. Writing sed Scripts
3.2 A Line-Up of Characters Book Index 4. Writing sed Scripts

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System