There are two Linux commands, and one related concept, that are extremely
powerful and that you should take the time to master because they will save you hours of work...
(Concept) Regular Expressions:
A very lovely, fanciful name for "a pattern for matching strings," and also for slicing pieces out of those strings. (See: man 7 regex
.) The cryptic "^#
" is a pattern which matches "the character '#' occurring at the beginning of a line." The even-more-cryptic "^[:space:]*#
" is a pattern which matches "the character '#', optionally preceded by zero or more blanks, tabs, or other "white space" characters,
occurring at the beginning of a line."
, which filters out the lines of a file which match (or which do not
match, a particular regular-expression. (See: info grep
, which is an even more sophisticated program for parsing (splitting things out of...) text files. An AWK "program" consists of a list of regular-expressions or conditions, and a corresponding series of statements which tell AWK what to do when each expression or condition is matched. (See: info awk
These commands and their descriptions were written by rocket scientists (literally)
, so they're rather obscure to say the least, but as usual, the essential idea
behind each tool or concept is a simple one. Start with a firm grip on what that simple idea is, read slowly and multiple times, and the various complexities will snap into place around it. The time spent is well worth it. These are power