Created
May 8, 2012 03:01
-
-
Save ksysctl/2632232 to your computer and use it in GitHub Desktop.
Remove spaces, sample fuction usign bash shell
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
#!/bin/bash | |
# original string, with spaces | |
my_var=" Fuck You! . "; | |
echo $my_var; | |
# the function | |
function trim() { | |
local string=$@; | |
string=${string//[[:space:]]}; | |
echo $string; | |
} | |
# passing one argument | |
my_var=$(trim $my_var); | |
# modified string, without spaces | |
echo $my_var; | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment