I write a bash script or two every month so I thought I'm okay. But then came along the very first example:
trim_string() {
# Usage: trim_string " example string "
: "${1#"${1%%[![:space:]]*}"}"
: "${_%"${_##*[![:space:]]}"}"
printf '%s\n' "$_"
}
Ok, so the : is somehow a temporary variable...
Then there is a variable starting at $ and you lost me :D
Can someone break down that line for me? What the hell is going on here? : "${1#"${1%%[![:space:]]*}"}"