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