How to append a text file?

i have to append a text file
grep for a word, if found, put comment in starting of the line.

here is an example

cat test.sh
bin/ksh
Hello World
Test Message
:wq!

search for "bin" word in test.sh file if found comment it out at starting of the line:

Output as follows:

#bin/ksh
Hello World
Test Message

try

$ sed 's/^bin*\//#bin\//g' file

OR

$ awk '/^bin/{$0="#"$0}1 file

Resulting

#bin/ksh
Hello World
Test Message

put ! if required

To APPEND a textfile....

cat filetoadd >> filegetsaddedhere

or :

sed 's/^bin.*/#&/'

hi

actually i have the file as follow:

policyserver="something.com Hello World
policyserver="something_new.com:44441
Test Message

how do i search for policyserver="something.com and put # (comment)

OUTPUT as follow:

#policyserver="something.com Hello World
policyserver="something_new.com:44441
Test Message---------- Post updated at 06:45 PM ---------- Previous update was at 06:02 PM ----------

it is working now

 awk '/^policyserver="something.com/{$0="#"$0}1' file

Thanks to all

Try:

sed '/^policyserver="something.com Hello World /s/^/#/' file