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