Created
February 2, 2013 17:08
-
-
Save nottsknight/4698334 to your computer and use it in GitHub Desktop.
BASH function to escape all ' ' characters in a string, e.g. for formatting a file name for use over scp
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
#!/usr/bin/env bash | |
function escapeSpaces () { | |
if [[ -n $1 ]]; then | |
string=`echo $1 | sed -r 's/[ ]+/\\\\\\ /g'` | |
echo "$string" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment