sed, replace first line

You can use sed with something like

sed '1 s/^.*$/<?php/'

The 1 part only replaces the first line. Then, thanks to the s command, it replaces the whole line by <?php.

To modify your files in-place, use the -i option of GNU sed.

Leave a Comment