Bash
String Manipulation
${str:position} # substring starting at position
${str:position:len} # substring starting at position with length len
${str#ubstring} # delete shortest match from front
${str##substring} # delete longest match from front
${str%substring} # delete shortest match from back
${str%%substring} # delete longest match from back
${str/pattern/replacement} # pattern replace
${str/#pattern/replacement} # pattern replace at front
${str/%pattern/replacement} # pattern replace at end
${str//pattern/replacement} # global pattern replace
${str^^} # convert to UPPER-CASE
${str,,} # convert to lower-caseParameter Substituion
${str-default} # set 'default' if not set
${str:-default} # set 'default' if not set (even if declared null)
${str=default} # set 'default' if not set
${str:=default} # set 'default' if not set (even if declared null)
${str+value} # set 'value' if $str is set, otherwise set null
${str:+value} # set 'value' if $str is set (even if declared null), otherwise set null
${str?error} # abort with 'error' if not set
${str:?error} # abort with 'error' if not set (and not null)Variables
Arrays
Hashes
Here Documents
Debugging Scripts
Writing Safer Scripts
Network Connections
File Operators
String Operators
Simulate Reading From a File
History
History Handling
Adding Timestamps
Easier History Navigation
History Hardening
Misc
Waiting for child processes
Kill childs on exit
Command Completion
Kill all childs on exit
Apply ulimit Changes Instantly
PS1: Escape Non-Print Chars
Last updated