I have a script that sets a variable. It is usually an URL that has been copied from a HTML file and then that variable is used.I take the copied text/clipboard contents using xclip -out and set that as a variable - let's say $CLIP. However, the copied URL can sometimes have unwanted characters, such as ,',` etc. I want the script to replace all of those with spaces.
Script that removes undesired characters from variable
bash;shell script
the copied URL can sometimes have unwanted characters, such as ,',`  etc. I want the script to replace all of those with spaces.You could use sed for this.If your $url variable looks something like this:echo $url http://1f,oo2b`a'r.comThis sed replaces all the unwanted chars with spaces:echo $url | sed 's/[^a-zA-Z0-9:/\.]/ /g'http://1f oo 2b a r.com