I have a script which takes user input and does a lot of things. One thing which I am worried about is it takes a file name and removes that file. e.g. rm -rf $arg1.
A user could technically input / in this arg and break things. How do I make it so I escape all symbols (my requirement is just letters and numbers as everything happens in one dir) before I actually execute the rm command.
I have come up with an
echo "$name" | grep -v symbols > $newname
I'm not sure if this is a good way of doing it. What are your suggestions on this.