Here's one I'm testing using Bash string manipulation:Moose On The Loose wrote: It seems worth the work to create an "escape" script that does all the changes to a string. Then any script that needs to not have a character taken to be a special character can use it. This would be like the thing in JavaScript.
Code: Select all
#!/bin/bash
### SED script
VAR="$1"
VAR="${VAR//\/\\}"
VAR="${VAR//\//\/}"
VAR="${VAR//\*/\*}"
VAR="${VAR//\[/\[}"
VAR="${VAR//\]/\]}"
VAR="${VAR//\-/\-}"
VAR="${VAR//\^/\^}"
echo "$VAR"
VAR="/usr/bin/myfile-2.1[34]"
FILE=`SED "$VAR"`
sed "/${FILE}/d" ./list