This is where you will find information on how to work with bash strings
String Types
Using single or double quotes matter!
NAME="Stefan"
echo "Hi $NAME" #=> Hi Stefan
echo 'Hi $NAME' #=> Hi $NAMESingle quotes prevent you from using Bash Inline Functions ( $() syntax )
Get Length Of String
my_string="hello"
echo "${#my_string}" # Output: 5Substring Extraction
my_string="abcdefg"
echo "${my_string:2:3}" # Output: cdeRemoving Substrings
file_path="/home/user/document.txt"
echo "${file_path#*/}" # Output: home/user/document.txtfile_path="/home/user/document.txt"
echo "${file_path##*/}" # Output: document.txtfilename="document.txt"
echo "${filename%.txt}" # Output: documentfilename="archive.tar.gz"
echo "${filename%%.*}" # Output: archiveReplacing Substrings
text="hello world, hello again"
echo "${text/hello/hi}" # Output: hi world, hello againCase Conversion
word="hello"
echo "${word^^}" # Output: HELLOword="WORLD"
echo "${word,,}" # Output: world