Basic sed question:
This sed substitution works fine to replace a string of Ns with a Z:
cat test1 | sed -E "s/N{10}/Z/g"
But the reverse replaces a Z with the literal string "N{10}"
cat test2 | sed -e "s/Z/N{10}/g"
and returns something like this: AAAA**N{10}**AAAA
How can I replace "Z" with a string of 10 Ns? I know I can key in NNNNNNNNNN into the sed command, but I’m trying to understand the syntax. For some reason N{10} works as in the to-be-replaced but not as replace-with. I’ve tried to to this a variety of ways, but can’t find anything that works.
Any advice will be appreciated.
>Solution :
perl can do it:
perl -pe 's/Z/N x 10/e' file
With N x 10, you ask explicitly to repeat 1O times N