Search code examples
unixsedsolaris

dollar($) -variable assignment is not working in my sed command


The below command works fine.

sed -n '/9/1/16 2:22/,/9/1/16 2:23/ p' /app/err.txt

But when i do it in below way the command results nothing:

$ s1="9\/1\/16"
$ t1="2:22"
$ s2="9\/1\/16"
$ t2="2:23"
$ sed -n '/$s1 $t1/,/$s2 $t2/ p' /app/err.txt

Please let me know how can i achieve it..!?


Solution

  • Try to use double quotes instead of single quotes with variables, e.g. "$s1". And | separators instead of /.