I have a file which contains a very long string of characters and I would like to replace a substring of it with Ns. Example:

test

```
ABCDABCDABCD

```

I would like to replace a substring of it with all letters N with awk command and sed, all the characters from index 5 to 8, so the total length of letter N is 4.

Output

```
ABCDNNNNABCD

```

I tried something like this:

```
awk '{ v=substr($0,5,4); sed -i "s/$v/N/g";print substr($0,1,4)""v""substr($0,9,12)}' test

```

however, this command seems to give this output:

```
ABCDABCDABC

```

And no substitution was made

I would like to have in the code the number of the index from where to start the substitution, (here, for example, is 5) and the length number of the substitution ( here 4), so I can just modify these numbers in case I want to start in another position and for a different length of substitutions because in reality, I have a string with thousands of letter and I want to replace hundreds of characters so substitution of pattern does not work in my case