# BASH Meta-Characters - `command-1 | command-2` to pipe output of command-1 to command-2 - `command-1 || command-2` to only run command-2 if command-1 fails - similar to an XOR - \ escape character - `command-1 &` run command-1 in background - `command-1 && command-2` run command -1, then command-2 if command-1 is successful - `command-1 ; command-2` allows you to run command-1, then command-2 regardless of success/failure - `command > file_name` to redirect to file with overwrite - `command >> file_name` to append to file - `$three=3` to assign a variable - `$three == 3` to test for equality - `$three != 3` to test for inequality - `command-1 !(string)` allows you to express exceptions to a command ![[images/Pasted image 20250803195824.png]] # Regular Expression (RegEx) Meta-Characters - `^` for start of line - `
for end of line - `*` represents zero or more occurrences of the preceding character or group - For example, `a*b` would match `b`, `ab`, `aab` - subtle difference between regex and shell globbing - `?` or `.` for singular character wildcard - `.*` represents a pattern that matches zero or more occurrences of any character (except newline) - Commonly used to match an arbitrary string of characters - `\` to escape certain characters - `\n` for newline character - `\r` for carriage return - `\t` for horizontal tab - `[abc]` or `[a-c]` for matching a class of characters - `[^abc]` or `[^a-c]` for matching anything but the class of characters - `regex1 | regex2` to match either regex - brace expansion: iterate through all options in braces ![[images/Pasted image 20250805200816.png]] # RegEx Supported Apps - `gawk` or `mawk` has built-in support ![[images/Pasted image 20250803135519.png]] - use `sed -f` - use `egrep` or `grep -E` - use double square brackets for BASH tests and conditionals