1

上部に著作権を追加する必要があるPHPスクリプトがあります。後に表示したいだけです

追加する必要があるものは次のとおりです。

/**
 * MySoftware
 *
 * This file is part of MySoftware.
 *
 * MySoftware is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MySoftware is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MySoftware.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @copyright   Copyright MySoftware
 * @license     GNU Public License V3.0
*/

上記のメッセージの前後に空白行を追加して、可能であれば各ファイルでより目立つようにするとよいでしょう。

これをすべてのphpファイルの先頭に追加する最も速い方法は何でしょうか?数百あり、それらすべてを1つのメインフォルダー/サブフォルダーに移動したので、コマンドラインを使用して再帰的に実行し、それぞれの先頭に追加できると考えていました。

誰かがコマンドラインまたは他の方法でこれを行う方法のサンプルスクリプト/コードを投稿できれば、それは大いにありがたいです!

4

2 に答える 2

2

たとえば、テキストをファイルに保存してから/tmp/header、次のスクリプトを実行します。

DIR=/your/php/files/dir
for f in $(find ${DIR} -iname "*.php" -type f 2>/dev/null) ; do
    cat /tmp/header "${f}" > /tmp/tmp_file || continue
    /bin/mv /tmp/tmp_file "${f}"
done
于 2012-11-26T03:22:58.977 に答える
0
#!/bin/bash
text="Hello world
What's up?"

exec 3<> $1 && awk -v TEXT="$text" 'BEGIN {print TEXT}{print}' $1 >&3

それを試してみてください。

于 2012-11-25T23:28:14.937 に答える