How to insert strings at certain position

Hi,
I need to insert strings "0000 00" at the each line within the file.
The postion is 37 to 42.

ex.
name1 name2 0000 00
nam name 0000 00

The "0000 00" in two lines should be lined up.
I don't know why it's not lined up when I posted it.
Can anyone help?

not tested......

sed 's/^\(.\{36\}\)\(.*\)/\10000 00\2/' myFile

Hi,
I am trying to utilize length function to calculate the postion to insert the string.

BEGIN { FS = "," }
i=length($2)
{printf "%s %s %s\n", $1,$2,substr("0",28-i}

It's just idea now. I am working to get it work.

??

I thought you already had known the position..... - it does not seem to be the case.
what your sample file look like AND where do you need to insert your text?

sorry,
Here is the sample:
1089 KEVIN_RIDDLE
1137 STEPHEN_SMITH
1214 MELISA_someone
1267 SANDY_name

Here is the file I am looking for:

1089 KEVIN_RIDDLE                         0000 00
1137 STEPHEN_SMITH                        0000 00
1214 MELISA_someone                       0000 00
1267 SANDY_name                           0000 00

( I don't know why I post it the "0000 00" is not lined up but they should be)
Because length of people's names are different, the space between the "0000 0" and name is different. But I 'd like "0000 00" in different rows to line up.
Maybe position 37 .

I hope I made it clear..

Thanks a lot!

enclose you sample file in the [ code] and [ /code] vB codes. Click here for the complete list of codes.

try:

nawk '{ print sprintf("%-36s", $0), "0000 00" }' myFile

Hi,
I forgot to mention: I need to change FS from "," to balnk space before I do add strings.
1089, KEVIN_RIDDLE
1137, STEPHEN_SMITH
1214, MELISA_someone
1267, SANDY_name

I am trying to manipulate the OFS and combine it with your code.
But not sucessful.....
I also don't quite understand the code you provided, it worked wonderfully.
I just don't understand why do you need to put print before sprintf?

Thanks a lot!

one way.....

nawk -v OFS=', ' '{ $1=$1; print sprintf("%-36s", $0) " 0000 00" }' myFile

I am still getting "," as OFS.
So I changed OFS=', ' to OFS=' ' ,
But the same thing happend again.

1089, KEVIN_RIDDLE 0000 00
1137, STEPHEN_SMITH 0000 00
1214, MELISA_someone 0000 00
1267, SANDY_name 0000 00

hmmmmm....... I thought that's what you have wanted!
Could you [as always] post the exact complete desired output, pls.

Sorry.
OK. first one is what I got by running the code you provided:
1089, KEVIN_RIDDLE 0000 00

The one below is the one that I desired:

1089 KEVIN_RIDDLE 0000 00

hmmm... maybe I'm getting "thick sculled', but....
didn't my original/first post attempt to do just that?

nawk '{ print sprintf("%-36s", $0), "0000 00" }' myFile

Oh, my god, I think I am too bad at communication.
Maybe that's why I am still just a poor programmer...

OK.
This is the file I originally had:
1089, KEVIN_RIDDLE
1137, STEPHEN_SMITH
1214, MELISA_someone
1267, SANDY_name

Two things I'd like to get from this file:

  1. replace the comma with space for OFS
  2. Add "0000 00" at each line of the original file according to the length of the name.

So this is going to be the final file I'd like to see:

1089 KEVIN_RIDDLE [right]0000 00[/right]
1137 STEPHEN_SMITH [right]0000 00[/right]
1214 MELISA_someone [right]0000 00[/right]
1267 SANDY_name [right]0000 00[/right]

The "0000 00" should be aligned from right side

ok, now we're getting somewhere!

nawk -v FS=',' -v OFS=' ' '{ $1=$1; print sprintf("%-36s", $0), "0000 00" }' myFile

Thank you so much for your help!

I don't know what to do without this website!