(echo "abc*****def";echo "def")|awk '/abc/{match($0,"[*]+");gsub("[*]","-",substr($0,RSTART,RLENGTH));print substr($0,1,RSTART-1),substr($0,RSTART+RLENGTH);} !/abc/{print}'