pictoru pictoru - 2 months ago 9
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.

Thanks!

Answer

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
Comments