Start with this script:
#!/bin/bash
line1="value1"
line2="value2"
< input_file sed -p "/$line1/,/$line2/p"
And it works fine. It prints out only those lines between $line1 and $line2.
But then make this change:
line1="value1/something"
And sed complains with an error because of the $line1 containing a slash.
What I would like to be able to do is simply change the delimiter:
#!/bin/bash
line1="value1"
line2="value2"
< input_file sed -p "%$line1%,%$line2%p"
And NOT have to do any Bash scripting on $line1 or $line2 such as this hackaround:
line1=$(echo "value1/something" | sed 's%/%\\/%g')
I want to do this all within sed, not with anything else such as awk, tr, etc, as I already know how to do that. If that is simply not possible within sed syntax, then that is a viable answer.
Update: sed version: sed (GNU sed) 4.5