Alternative to `sed -i` on Solaris

Viewed 48344

On Linux sed -i will modify the input files in place. It doesn't work on Solaris, though.

sed -i '$ s/OLD/NEW/g' test        
sed: illegal option -- i

What can I use in place of sed -i on Solaris?

3 Answers

One more "one-line" command which works on Solaris 11 host in bash enviroment:

for i in `cat strings_to_delete.txt`
do 
    sed "/$i/d" file.to_edit.txt > file.edited.txt &&
        mv file.edited.txt file.to_edit.txt
done

It deletes strings from file strings_to_delete.txt in file.to_edit.txt. File strings_to_delete.txt contains multiple lines with one string per line.

Related