is this possible to change first 4 ( or more ) occurences of string in this scenario using SED (opposite of SED -r 's/[^[:space:]]*/TEST/4g'):
TEST TEST TEST TEST five six seven
I get it working with reversing words order in line using AWK twice, but this is long, complex and I want to get this with just SED:
echo one two three four five six seven | awk '{for(i=NF;i>=1;i--) printf "%s ", $i;print ""}' | sed -r 's/[^ ]*/TEST/4g' | awk '{for(i=NF;i>=1;i--) printf "%s ", $i;print ""}'
Also maybe there is option to change ranges of occurence like 3-5, 6-12, ...?
Aucun commentaire:
Enregistrer un commentaire