Bash - Trim string of white spaces

A Bash One-liner Function: Trim White Spaces
gsub - global sub, instead of sub that does 1st only gsub man page

trim <- function(s) gsub("^[[:space:]]+|[[:space:]]+$","",s)