Created
March 4, 2012 21:31
-
-
Save wraithmonster/1974878 to your computer and use it in GitHub Desktop.
Strip whitespace & trailing slashes in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# References: | |
# http://bit.ly/bash-exit-status | |
# http://bit.ly/bash-remove-slash | |
# http://www.delorie.com/gnu/docs/wget/wget_27.html | |
# Strip whitespace | |
WS=`expr "$1" : '[[:space:]]*\(.*\)[[:space:]]*$'` | |
# Strip whitespace and remove any trailing slashes | |
WS_AND_SLASHES=`expr "$1" : '[[:space:]]*\(.*\)[[:space:]]*$' | sed -e 's/\\/$//g'` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment