updating a single line by script

hi,
I'm trying to add a # to the beginning of the line where the a word is included.

and the i want to run the whole original script.

and if possible I would prefer that line would stay in the same order in the text file, the line which includes the word.

Thanks,

sed 's/.*word/#&/'

Thank you,

I am really new at shell scripting.

However I have a little problem when I do this.

Lets say that my original script is as follows;

#!/bin/ksh
echo "a"
echo "b"
echo "c"

and the update script;

#!/bin/ksh
sed 's/.*b/#&/' original.sh
./original.sh

the result i obtain is as follows;

#!/bin/ksh
echo "a"
#echo"b"
echo "c"

and the original.sh is not updated

how can i update original.sh or how can i see the output as;

a
c

If you only see the updated result on your screen (std out) then try this:

sed 's/.*b/#&/' original.sh > temprorary.sh
mv temprorary.sh original.sh

mv original.sh old.sh
sed 's/.*b/#&/' old.sh >original.sh
chmod 755 original.sh

Thank you so much..

You need the mode to make it actually executable, along with the #! first line.

I konw that one,
I added the mode to the script and right now it works perfectly...
Thanks again..

Otherwise, without the execute permission but with read permission you can

ksh original.sh

by the way if you put

#!/usr/bin/ksh

as a first line, it might be a good idea to name it

original.ksh

instead ...

Thank again,

What should i do if I want to to remove the #, I have tried coule of things on the sed you've told me, however it didnt work.

Now if I have sth like

echo "a"
#echo"b"
echo "c"

when I tried I ended up deleting everything until the word I've searched;

echo "a"
b"
echo "c"

but I want to have

echo "a"
echo"b"
echo "c"

mv yourfile yourfile.old
sed 's/#\(.*\)/\1/' yourfile.old >yourfile
rm yourfile.old