In my bash script, i am trying to execute following Linux command:
sed -i "/$data_line/ d" $data_dir
$data_line is entered by user and it may conatain special characters that could brake regex.
How can i escape all of the possible special characters in $data_line before i execute sed command?
You might be able to use this technique to protect the selector. The lines marked with “
*****” below are the significant lines. The others are mostly for testing and demonstration. The key is to use a character that doesn’t appear in the user input to delimit the selector address.