Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Last active September 29, 2022 00:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhyland87/32ffcdef4b9a71a0328fada9ca71da6b to your computer and use it in GitHub Desktop.
Save jhyland87/32ffcdef4b9a71a0328fada9ca71da6b to your computer and use it in GitHub Desktop.
function __trim {
if test -p /dev/stdin; then
data="$(</dev/stdin)"
elif test -n "${1}"; then
data="$*"
else
return 1
fi
echo "${data}" | sed -E -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*$//g'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment