Problem with variables in sed

Hello!

I have a problem to insert variables with sed... And I can't find the solution. :confused:
I would like to display one/few line(s) between 2 values.

This line works well

sed -n '/Dec 12 10:42/,/Dec 12 10:47/p'

Thoses lines with variables doesn't work and I don't find the solution...

MMCHAR=Dec
DD=12
HBEGINBCK=10:42
HENDBACKUP=10:47
sed -n '/$MMCHAR $DD $HBEGINBCK/,/$MMCHAR $DD $HENDBACKUP/p'
sed -n '/'$MMCHAR $DD $HBEGINBCK'/,/'$MMCHAR $DD $HENDBACKUP'/p'
sed -n '/"$MMCHAR $DD $HBEGINBCK"/,/"$MMCHAR $DD $HENDBACKUP"/p'

If someone have the solution... Thanks!!:b:

Can you try this:

sed -n "/$MMCHAR $DD $HBEGINBCK/,/$MMCHAR $DD $HENDBACKUP/p"
1 Like

Thank you balajesuri!!!!!!