using sed to print next line after match
- by smokinguns
I came across various examples on printing next line after a match, that use awk and sed.
I'm using it in my code and it works fine. Now I want to use a variable instead of a hardcoded value for the pattern match. The search pattern string includes forward slashes "/". How do I use a variable that has "/" in it and use it to print the next line after the match? The following doesn't seem to work:
var="/somePath/to/my/home"
val=`echo -e "$someStr" | sed -n ':$var:{n;p;}'`
In this case, val is always blank. I'm using using ":" as the delimiter instead of "/". I'm on a Mac OS X.