pictoru pictoru - 1 year ago 70
PHP Question

Change first line recursively in all php files using bash

I have a WordPress site and want to change first line of all php files recursively using bash. How should I do? I am not very familiar with bash.


Answer Source

Change first line to some other line:

sed -i '1s/.*/changed line/' *.php

Adding a line before first line:

sed -i '1s/^/changed line\n/' *.php