Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created January 9, 2014 02:28
Show Gist options
  • Select an option

  • Save coderofsalvation/8328455 to your computer and use it in GitHub Desktop.

Select an option

Save coderofsalvation/8328455 to your computer and use it in GitHub Desktop.
remove leading and trailing whitespaces
# remove leading and trailing whitespaces
# usage: echo " foo bar " | trim
trim(){
cat - | sed -e 's/^ *//g' -e 's/ *$//g'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment