複数のファイルで同様の置換(diffには十分簡単ではありません)を実行する賢明な方法は何ですか?

複数のファイルで同様の置換(diffには十分簡単ではありません)を実行する賢明な方法は何ですか?

私はすべて同じ変更を必要とするファイルの束(45個、クレイジーではなく手動で編集するには多すぎます)を持っています(この質問の最後に3つの違いが表示されます)。

ほとんどのコマンドライン検索および置換ツールは行単位の置換のみをサポートしているため、機能しません。

タスクを実行できるコマンドラインツールはありますか?基本的に、完全な正規表現を1行に入れずに複数行の正規表現検索と逆参照置換を実行する(つまり、ファイルまたは標準入力から読み取る必要があります)、十分ですがこれを可能にするより良い解決策があるかもしれません。 。


--- a/editfile.html
+++ b/editfile.html
@@ -60,7 +60,5 @@

 <script type="text/javascript">
-    $(document).ready(function() {
-        editFileInit(opts);
-    });
+    initPage('editFile', opts);
 </script>
 {% endblock %}
diff --git a/gallery.html b/gallery.html
index 4a07f70..81084ad 100644
--- a/exodus/templates/gallery.html
+++ b/exodus/templates/gallery.html
@@ -87,9 +87,7 @@

     <script type="text/javascript">
-        $(document).ready(function() {
-            galleryInit({
-                editTitleUrl: {{ csrf_url_for('gallery_editpictitle')|tojson|safe }},
-                delPicUrl: {{ csrf_url_for('gallery_delpic')|tojson|safe }}
-            });
+        initPage('gallery', {
+            editTitleUrl: {{ csrf_url_for('gallery_editpictitle')|tojson|safe }},
+            delPicUrl: {{ csrf_url_for('gallery_delpic')|tojson|safe }}
         });
     </script>
diff --git a/stream_history.html b/stream_history.html
index 783fea4..ea837fa 100644
--- a/exodus/templates/stream_history.html
+++ b/exodus/templates/stream_history.html
@@ -25,8 +25,6 @@

     <script type="text/javascript">
-        $(document).ready(function() {
-            songHistoryInit({
-                dataURL: {{ url_for('stream_history_json')|tojson|safe }}
-            });
+        initPage('songHistory', {
+            dataURL: {{ url_for('stream_history_json')|tojson|safe }}
         });
     </script>

インデントが維持されないと大きな問題になりません。

ベストアンサー1

:exモードを使用すると、viで実行できるすべての操作をスクリプトに変換できます。編集する

edしかし、vi面倒なユーザーフレンドリーなインターフェースが邪魔になり、速度を遅くしません。

冗談はさておき、edテキストファイルスクリプトを編集するのに便利なツールです。

おすすめ記事