|
| 1 | +# Table of Contents |
| 2 | + |
| 3 | +<!-- vim-markdown-toc GFM --> |
| 4 | + |
| 5 | +* [Strings](#strings) |
| 6 | + * [Trim leading and trailing white-space from string](#trim-leading-and-trailing-white-space-from-string) |
| 7 | + * [Trim all white-space from string and truncate spaces](#trim-all-white-space-from-string-and-truncate-spaces) |
| 8 | + * [Use regex on a string](#use-regex-on-a-string) |
| 9 | + * [Split a string on a delimiter](#split-a-string-on-a-delimiter) |
| 10 | + * [Change a string to lowercase](#change-a-string-to-lowercase) |
| 11 | + * [Change a string to uppercase](#change-a-string-to-uppercase) |
| 12 | + * [Trim quotes from a string](#trim-quotes-from-a-string) |
| 13 | + * [Strip all instances of pattern from string](#strip-all-instances-of-pattern-from-string) |
| 14 | + * [Strip first occurrence of pattern from string](#strip-first-occurrence-of-pattern-from-string) |
| 15 | + * [Strip pattern from start of string](#strip-pattern-from-start-of-string) |
| 16 | + * [Strip pattern from end of string](#strip-pattern-from-end-of-string) |
| 17 | + * [Check if string contains a sub-string](#check-if-string-contains-a-sub-string) |
| 18 | + * [Check if string starts with sub-string](#check-if-string-starts-with-sub-string) |
| 19 | + * [Check if string ends with sub-string](#check-if-string-ends-with-sub-string) |
| 20 | +* [Arrays](#arrays) |
| 21 | + * [Reverse an array](#reverse-an-array) |
| 22 | + * [Remove duplicate array elements](#remove-duplicate-array-elements) |
| 23 | + * [Random array element](#random-array-element) |
| 24 | + * [Cycle through an array](#cycle-through-an-array) |
| 25 | + * [Toggle between two values](#toggle-between-two-values) |
| 26 | +* [Loops](#loops) |
| 27 | + * [Loop over a range of numbers](#loop-over-a-range-of-numbers) |
| 28 | + * [Loop over a variable range of numbers](#loop-over-a-variable-range-of-numbers) |
| 29 | + * [Loop over an array](#loop-over-an-array) |
| 30 | + * [Loop over an array with an index](#loop-over-an-array-with-an-index) |
| 31 | + * [Loop over the contents of a file](#loop-over-the-contents-of-a-file) |
| 32 | + * [Loop over files and directories](#loop-over-files-and-directories) |
| 33 | +* [File handling](#file-handling) |
| 34 | + * [Read a file to a string](#read-a-file-to-a-string) |
| 35 | + * [Read a file to an array (*by line*)](#read-a-file-to-an-array-by-line) |
| 36 | + * [Get the first N lines of a file](#get-the-first-n-lines-of-a-file) |
| 37 | + * [Get the last N lines of a file](#get-the-last-n-lines-of-a-file) |
| 38 | + * [Get the number of lines in a file](#get-the-number-of-lines-in-a-file) |
| 39 | + * [Count files or directories in directory](#count-files-or-directories-in-directory) |
| 40 | + * [Create an empty file](#create-an-empty-file) |
| 41 | + * [Extract lines between two markers](#extract-lines-between-two-markers) |
| 42 | +* [File Paths](#file-paths) |
| 43 | + * [Get the directory name of a file path](#get-the-directory-name-of-a-file-path) |
| 44 | + * [Get the base-name of a file path](#get-the-base-name-of-a-file-path) |
| 45 | +* [Variables](#variables) |
| 46 | + * [Assign and access a variable using a variable](#assign-and-access-a-variable-using-a-variable) |
| 47 | +* [Escape Sequences](#escape-sequences) |
| 48 | + * [Text Colors](#text-colors) |
| 49 | + * [Text Attributes](#text-attributes) |
| 50 | + * [Cursor Movement](#cursor-movement) |
| 51 | + * [Erasing Text](#erasing-text) |
| 52 | +* [Parameter Expansion](#parameter-expansion) |
| 53 | + * [Indirection](#indirection) |
| 54 | + * [Replacement](#replacement) |
| 55 | + * [Length](#length) |
| 56 | + * [Expansion](#expansion) |
| 57 | + * [Case Modification](#case-modification) |
| 58 | + * [Default Value](#default-value) |
| 59 | +* [Brace Expansion](#brace-expansion) |
| 60 | + * [Ranges](#ranges) |
| 61 | + * [String Lists](#string-lists) |
| 62 | +* [Arithmetic](#arithmetic) |
| 63 | + * [Simpler syntax to set variables](#simpler-syntax-to-set-variables) |
| 64 | + * [Ternary tests](#ternary-tests) |
| 65 | +* [Traps](#traps) |
| 66 | + * [Do something on script exit](#do-something-on-script-exit) |
| 67 | + * [Ignore terminal interrupt (CTRL+C, SIGINT)](#ignore-terminal-interrupt-ctrlc-sigint) |
| 68 | + * [React to window resize.](#react-to-window-resize) |
| 69 | + * [Do something before every command.](#do-something-before-every-command) |
| 70 | + * [Do something when a shell function or a sourced file finishes executing](#do-something-when-a-shell-function-or-a-sourced-file-finishes-executing) |
| 71 | +* [Performance](#performance) |
| 72 | + * [Disable Unicode](#disable-unicode) |
| 73 | +* [Obsolete Syntax](#obsolete-syntax) |
| 74 | + * [Shebang](#shebang) |
| 75 | + * [Command Substitution](#command-substitution) |
| 76 | + * [Function Declaration](#function-declaration) |
| 77 | +* [Internal Variables](#internal-variables) |
| 78 | + * [Get the location to the `bash` binary](#get-the-location-to-the-bash-binary) |
| 79 | + * [Get the version of the current running `bash` process](#get-the-version-of-the-current-running-bash-process) |
| 80 | + * [Open the user's preferred text editor](#open-the-users-preferred-text-editor) |
| 81 | + * [Get the name of the current function](#get-the-name-of-the-current-function) |
| 82 | + * [Get the host-name of the system](#get-the-host-name-of-the-system) |
| 83 | + * [Get the architecture of the Operating System](#get-the-architecture-of-the-operating-system) |
| 84 | + * [Get the name of the Operating System / Kernel](#get-the-name-of-the-operating-system--kernel) |
| 85 | + * [Get the current working directory](#get-the-current-working-directory) |
| 86 | + * [Get the number of seconds the script has been running](#get-the-number-of-seconds-the-script-has-been-running) |
| 87 | + * [Get a pseudorandom integer](#get-a-pseudorandom-integer) |
| 88 | +* [Information about the terminal](#information-about-the-terminal) |
| 89 | + * [Get the terminal size in lines and columns (*from a script*)](#get-the-terminal-size-in-lines-and-columns-from-a-script) |
| 90 | + * [Get the terminal size in pixels](#get-the-terminal-size-in-pixels) |
| 91 | + * [Get the current cursor position](#get-the-current-cursor-position) |
| 92 | +* [Conversion](#conversion) |
| 93 | + * [Convert a hex color to RGB](#convert-a-hex-color-to-rgb) |
| 94 | + * [Convert an RGB color to hex](#convert-an-rgb-color-to-hex) |
| 95 | +* [Code Golf](#code-golf) |
| 96 | + * [Shorter `for` loop syntax](#shorter-for-loop-syntax) |
| 97 | + * [Shorter infinite loops](#shorter-infinite-loops) |
| 98 | + * [Shorter function declaration](#shorter-function-declaration) |
| 99 | + * [Shorter `if` syntax](#shorter-if-syntax) |
| 100 | + * [Simpler `case` statement to set variable](#simpler-case-statement-to-set-variable) |
| 101 | +* [Other](#other) |
| 102 | + * [Use `read` as an alternative to the `sleep` command](#use-read-as-an-alternative-to-the-sleep-command) |
| 103 | + * [Check if a program is in the user's PATH](#check-if-a-program-is-in-the-users-path) |
| 104 | + * [Get the current date using `strftime`](#get-the-current-date-using-strftime) |
| 105 | + * [Generate a UUID V4](#generate-a-uuid-v4) |
| 106 | + * [Progress bars](#progress-bars) |
| 107 | + * [Get the list of functions from your script](#get-the-list-of-functions-from-your-script) |
| 108 | + * [Bypass shell aliases](#bypass-shell-aliases) |
| 109 | + * [Bypass shell functions](#bypass-shell-functions) |
| 110 | +* [Afterword](#afterword) |
| 111 | + |
| 112 | +<!-- vim-markdown-toc --> |
| 113 | + |
| 114 | +<!-- CHAPTER END --> |
| 115 | + |
0 commit comments