Regular Expression & Shell Scripting Flashcards
Regex:
Indentity (=)
Find a word that only matches the word you want to search for.
Regex:
Optionallity (?)
Zero or one. “This piece is matched if the wrapped atom appears in this position zero or one times”.
Regex:
Repetition (+)
One or more. “This piece is matched if the wrapped atom appears in this position one or more times”.
Regex:
Optional rep. (*)
Zero or more. “This piece is matched if the wrapped atom appears in this position zero or more times”.
Regex:
Abritrary q. ( {n,m} )
N to M times. “This piece is matched if the wrapped atom appears in this position at least n and at most m times”.
Wildcard:
.
The . metacharacter is an atom that matches any character.
Wildcard:
[abc]
Any of a, b or c. The bracket expression [abc] is an atom that matches any single character from the list of enclosed characters.
Wildcard:
Negated set ([^abc])
Anything except a, b or c. The bracket expression [^abc] is an atom that matches any single character from the list of enclosed characters.
Wildcard:
Rangers ([a-f])
Any between a and f. The bracket expression [a-f] is an atom that matches any single character in the range of characters from a to f.
[Gg] ?
The letter must start with G or g.
((aa | bb | cc)) ?
aa, bb or cc. The branch (aa | bb | cc) is treated as a single atom (it is a group) and matches if any of the enclosed subsequences of pieces aa, bb or cc matches.
^ in a line/string?
Defines the beginning of the string/line.
$ in a line/string?
Defines the end of a string/line.
Rm ?
Removes files
Ls ?
List of content in a driectory