Help with search and replace

Hi, I am using vi. I need help with search and replace.

I have a file close to 100 lines. I want to search /var and replace with rm /var.

/var/sadm/pkg/SUNWcsu/save/125378-03/undo.Z
/var/sadm/pkg/SUNWcsr/save/pspool/SUNWcsr/save/127718-02/undo.Z
/var/sadm/pkg/SUNWcsr/save/127718-02/undo.Z

My results should look like this..

rm /var/sadm/pkg/SUNWcsu/save/125378-03/undo.Z
rm /var/sadm/pkg/SUNWcsr/save/pspool/SUNWcsr/save/127718-02/undo.Z
rm /var/sadm/pkg/SUNWcsr/save/127718-02/undo.Z

Please help. I did :s didn't work. the rm word comes before /

:1,$s!/var!rm /var!g

Try this:

sed -e 's/^\/var/rm &/g' <file>  

The / separator is arbitrary. You can use a different separator such as ! as I used in this case.

Substitute /var at the beginning of the line only!

:1,$s!^/var!rm /var!