The Notes for Professionals book is compiled from Stack Overflow Documentation, the content is written by the beautiful people at Stack Overflow. Text content is released under Creative Commons BY-SA. See credits at the end of this book whom contributed to the various chapters. Images may be copyright of their respective owners unless otherwise specified
Book created for educational purposes and is not affiliated with group(s), company(s) nor Stack Overflow. All trademarks belong to their respective company owners
https://goalkicker.com/
Content
1-1
Content list
1-2
About
1-3
Chapter 1: Getting started with Bash
1-4
Section 1.1: Hello World
1-5
Section 1.2: Hello World Using Variables
1-6
Section 1.3: Hello World with User Input
1-7
Section 1.4: Importance of Quoting in Strings
1-8
Section 1.5: Viewing information for Bash built-ins
1-9
Section 1.6: Hello World in "Debug" mode
1-10
Section 1.7: Handling Named Arguments
1-11
Chapter 2: Script shebang
1-12
Section 2.1: Env shebang
1-13
Section 2.2: Direct shebang
1-14
Section 2.3: Other shebangs
1-15
Chapter 3: Navigating directories
1-16
Section 3.1: Absolute vs relative directories
1-17
Section 3.2: Change to the last directory
1-18
Section 3.3: Change to the home directory
1-19
Section 3.4: Change to the Directory of the Script
1-20
Chapter 4: Listing Files
1-21
Section 4.1: List Files in a Long Listing Format
1-22
Section 4.2: List the Ten Most Recently Modified Files
1-23
Section 4.3: List All Files Including Dotfiles
1-24
Section 4.4: List Files Without Using `ls`
1-25
Section 4.5: List Files
1-26
Section 4.6: List Files in a Tree-Like Format
1-27
Section 4.7: List Files Sorted by Size
1-28
Chapter 5: Using cat
1-29
Section 5.1: Concatenate files
1-30
Section 5.2: Printing the Contents of a File
1-31
Section 5.3: Write to a file
1-32
Section 5.4: Show non printable characters
1-33
Section 5.5: Read from standard input
1-34
Section 5.6: Display line numbers with output
1-35
Section 5.7: Concatenate gzipped files
1-36
Chapter 6: Grep
1-37
Section 6.1: How to search a file for a pattern
1-38
Chapter 7: Aliasing
1-39
Section 7.1: Bypass an alias
1-40
Section 7.2: Create an Alias
1-41
Section 7.3: Remove an alias
1-42
Section 7.4: The BASH_ALIASES is an internal bash assoc array
1-43
Section 7.5: Expand alias
1-44
Section 7.6: List all Aliases
1-45
Chapter 8: Jobs and Processes
1-46
Section 8.1: Job handling
1-47
Section 8.2: Check which process running on specific port
1-48
Section 8.3: Disowning background job
1-49
Section 8.4: List Current Jobs
1-50
Section 8.5: Finding information about a running process
1-51
Section 8.6: List all processes
1-52
Chapter 9: Redirection
1-53
Section 9.1: Redirecting standard output
1-54
Section 9.2: Append vs Truncate
1-55
Section 9.3: Redirecting both STDOUT and STDERR
1-56
Section 9.4: Using named pipes
1-57
Section 9.5: Redirection to network addresses
1-58
Section 9.6: Print error messages to stderr
1-59
Section 9.7: Redirecting multiple commands to the same file
1-60
Section 9.8: Redirecting STDIN
1-61
Section 9.9: Redirecting STDERR
1-62
Section 9.10: STDIN, STDOUT and STDERR explained
1-63
Chapter 10: Control Structures
1-64
Section 10.1: Conditional execution of command lists
1-65
Section 10.2: If statement
1-66
Section 10.3: Looping over an array
1-67
Section 10.4: Using For Loop to List Iterate Over Numbers
1-68
Section 10.5: continue and break
1-69
Section 10.6: Loop break
1-70
Section 10.7: While Loop
1-71
Section 10.8: For Loop with C-style syntax
1-72
Section 10.9: Until Loop
1-73
Section 10.10: Switch statement with case
1-74
Section 10.11: For Loop without a list-of-words parameter
1-75
Chapter 11: true, false and : commands
1-76
Section 11.1: Infinite Loop
1-77
Section 11.2: Function Return
1-78
Section 11.3: Code that will always/never be executed
1-79
Chapter 12: Arrays
1-80
Section 12.1: Array Assignments
1-81
Section 12.2: Accessing Array Elements
1-82
Section 12.3: Array Modification
1-83
Section 12.4: Array Iteration
1-84
Section 12.5: Array Length
1-85
Section 12.6: Associative Arrays
1-86
Section 12.7: Looping through an array
1-87
Section 12.8: Destroy, Delete, or Unset an Array
1-88
Section 12.9: Array from string
1-89
Section 12.10: List of initialized indexes
1-90
Section 12.11: Reading an entire file into an array
1-91
Section 12.12: Array insert function
1-92
Chapter 13: Associative arrays
1-93
Section 13.1: Examining assoc arrays
1-94
Chapter 14: Functions
1-95
Section 14.1: Functions with arguments
1-96
Section 14.2: Simple Function
1-97
Section 14.3: Handling flags and optional parameters
1-98
Section 14.4: Print the function definition
1-99
Section 14.5: A function that accepts named parameters
1-100
Section 14.6: Return value from a function
1-101
Section 14.7: The exit code of a function is the exit code of its last command
1-102
Chapter 15: Bash Parameter Expansion
1-103
Section 15.1: Modifying the case of alphabetic characters
1-104
Section 15.2: Length of parameter
1-105
Section 15.3: Replace pattern in string
1-106
Section 15.4: Substrings and subarrays
1-107
Section 15.5: Delete a pattern from the beginning of a string
1-108
Section 15.6: Parameter indirection
1-109
Section 15.7: Parameter expansion and filenames
1-110
Section 15.8: Default value substitution
1-111
Section 15.9: Delete a pattern from the end of a string
1-112
Section 15.10: Munging during expansion
1-113
Section 15.11: Error if variable is empty or unset
1-114
Chapter 16: Copying (cp)
1-115
Section 16.1: Copy a single file
1-116
Section 16.2: Copy folders
1-117
Chapter 17: Find
1-118
Section 17.1: Searching for a file by name or extension
1-119
Section 17.2: Executing commands against a found file
1-120
Section 17.3: Finding file by access / modification time
1-121
Section 17.4: Finding files according to size
1-122
Section 17.5: Filter the path
1-123
Section 17.6: Finding files by type
1-124
Section 17.7: Finding files by specific extension
1-125
Chapter 18: Using sort
1-126
Section 18.1: Sort command output
1-127
Section 18.2: Make output unique
1-128
Section 18.3: Numeric sort
1-129
Section 18.4: Sort by keys
1-130
Chapter 19: Sourcing
1-131
Section 19.1: Sourcing a file
1-132
Section 19.2: Sourcing a virtual environment
1-133
Chapter 20: Here documents and here strings
1-134
Section 20.1: Execute command with here document
1-135
Section 20.2: Indenting here documents
1-136
Section 20.3: Create a file
1-137
Section 20.4: Here strings
1-138
Section 20.5: Run several commands with sudo
1-139
Section 20.6: Limit Strings
1-140
Chapter 21: Quoting
1-141
Section 21.1: Double quotes for variable and command substitution
1-142
Section 21.2: Dierence between double quote and single quote
1-143
Section 21.3: Newlines and control characters
1-144
Section 21.4: Quoting literal text
1-145
Chapter 22: Conditional Expressions
1-146
Section 22.1: File type tests
1-147
Section 22.2: String comparison and matching
1-148
Section 22.3: Test on exit status of a command
1-149
Section 22.4: One liner test
1-150
Section 22.5: File comparison
1-151
Section 22.6: File access tests
1-152
Section 22.7: Numerical comparisons
1-153
Chapter 23: Scripting with Parameters
1-154
Section 23.1: Multiple Parameter Parsing
1-155
Section 23.2: Argument parsing using a for loop
1-156
Section 23.3: Wrapper script
1-157
Section 23.4: Accessing Parameters
1-158
Section 23.5: Split string into an array in Bash
1-159
Chapter 24: Bash history substitutions
1-160
Section 24.1: Quick Reference
1-161
Section 24.2: Repeat previous command with sudo
1-162
Section 24.3: Search in the command history by pattern
1-163
Section 24.4: Switch to newly created directory with !#:N
1-164
Section 24.5: Using !$
1-165
Section 24.6: Repeat the previous command with a substitution
1-166
Chapter 25: Math
1-167
Section 25.1: Math using dc
1-168
Section 25.2: Math using bash capabilities
1-169
Section 25.3: Math using bc
1-170
Section 25.4: Math using expr
1-171
Chapter 26: Bash Arithmetic
1-172
Section 26.1: Simple arithmetic with (( ))
1-173
Section 26.2: Arithmetic command
1-174
Section 26.3: Simple arithmetic with expr
1-175
Chapter 27: Scoping
1-176
Section 27.1: Dynamic scoping in action
1-177
Chapter 28: Process substitution
1-178
Section 28.1: Compare two files from the web
1-179
Section 28.2: Feed a while loop with the output of a command
1-180
Section 28.3: Concatenating files
1-181
Section 28.4: Stream a file through multiple programs at once
1-182
Section 28.5: With paste command
1-183
Section 28.6: To avoid usage of a sub-shell
1-184
Chapter 29: Programmable completion
1-185
Section 29.1: Simple completion using function
1-186
Section 29.2: Simple completion for options and filenames
1-187
Chapter 30: Customizing PS1
1-188
Section 30.1: Colorize and customize terminal prompt
1-189
Section 30.2: Show git branch name in terminal prompt
1-190
Section 30.3: Show time in terminal prompt
1-191
Section 30.4: Show a git branch using PROMPT_COMMAND
1-192
Section 30.5: Change PS1 prompt
1-193
Section 30.6: Show previous command return status and time
1-194
Chapter 31: Brace Expansion
1-195
Section 31.1: Modifying filename extension
1-196
Section 31.2: Create directories to group files by month and year
1-197
Section 31.3: Create a backup of dotfiles
1-198
Section 31.4: Use increments
1-199
Section 31.5: Using brace expansion to create lists
1-200
Section 31.6: Make Multiple Directories with Sub-Directories