$mod = "ABC "; $hier = `tac temp.xx | sed -n '/$mod /,/YYY/ p'| grep XXX`;