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