I work on shell script and I want to remove all space characters in a string.
On another question I saw a sed
command for replacing and tried to use it with sending null character in it:
echo \0 | sed "s/ /${text}/"
But it did not work.
Any other way to do this?
This deletes all space characters in the input:
echo some text with spaces | tr -d ' '
Another way using sed
:
echo some text with spaces | sed -e 's/ //g'
But... In your example there are no spaces, and it looks like you want to replace spaces with the content of the variable $text
... So not 100% sure this is what you're looking for. So if not, then please clarify.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With