Help with pipes in a file

I have to add pipes for particualr number of records in a file. For eg the file has 10 records and i need to add the "|" for records numbers 7 to 10 at particular positons as shown.

I need to add pipes in each of these records at positions 9, 11,,21 as like below.

Can some body let me know how i can acheive this.

use vi

7,10s/RW/|RW|/
7,10s/9999/|9999/

save and quit

thanks jgt.

nawk -f ds.awk myFile.txt

ds.awk:

function setFieldsByWidth(   i,n,FWS,start,copyd0)
{

  copyd0 = $0
  n = split(FIELDWIDTHS,FWS)

  if (n == 1) {
    print "Warning: FIELDWIDTHS contains only one fie"
    print "Attempting to continue." > "/dev/stderr"
  }

  start = 1
  for (i=1; i <= n; i++) {
    $i = substr(copyd0,start,FWS)
    start = start + FWS
  }
}
BEGIN {
  FIELDWIDTHS="8 2 10 9999"
  OFS="|"
}
FNR >=7 && FNR<=10 && !/^[  ]*$/ {
  saveDollarZero = $0 # if you want it later
  setFieldsByWidth()
  # now we can manipulate $0, NF and $1 .. $NF as we wish
  print $0
  next
}
1

Thanks Vgresh!!!! Can you help me with this please.

I have to add | at the end of the 8 th field in the below file and that too for all the reocrds in the file

The out put should look like this:

How i can do this. Please suggest.

sed '7,10s/\(.\{8\}\)\(.\{2\}\)\(.\{10\}\)/\1|\2|\3|/' input_file
sed 's/.\{8\}/&|/'

nawk -f ds.awk myFile.txt
ds.awk:

function setFieldsByWidth(   i,n,FWS,start,copyd0)
{

  copyd0 = $0
  n = split(FIELDWIDTHS,FWS)

  if (n == 1) {
    print "Warning: FIELDWIDTHS contains only one fie"
    print "Attempting to continue." > "/dev/stderr"
  }

  start = 1
  for (i=1; i <= n; i++) {
    $i = substr(copyd0,start,FWS)
    start = start + FWS
  }
}
BEGIN {
  FIELDWIDTHS="8 9999"
  OFS="|"
}
!/^[  ]*$/ {
  saveDollarZero = $0 # if you want it later
  setFieldsByWidth()
  # now we can manipulate $0, NF and $1 .. $NF as we wish
  print $0
  next
}
1

or Shell_Life's 'sed'