Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@khurshid-alam
Created July 28, 2016 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khurshid-alam/c24c5b64637547f8edcc46168ed32c66 to your computer and use it in GitHub Desktop.
Save khurshid-alam/c24c5b64637547f8edcc46168ed32c66 to your computer and use it in GitHub Desktop.
FOO=' test test test '
FOO_NO_EXTERNAL_SPACE="$(echo -e "${FOO}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
echo -e "FOO_NO_EXTERNAL_SPACE='${FOO_NO_EXTERNAL_SPACE}'"
# > FOO_NO_EXTERNAL_SPACE='test test test'
echo -e "length(FOO_NO_EXTERNAL_SPACE)==$(echo -ne "${FOO_NO_EXTERNAL_SPACE}" | wc -m)"
# > length(FOO_NO_EXTERNAL_SPACE)==14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment