0

約 1.5k ファイルから以下を削除またはコメントアウトする必要があり、それを行うのに非常に苦労しています。perlの検索/置換で考えられることはすべて試しましたが、どこにも行きません。アプローチに関する提案は役に立ちます。その上下のタブには、xml ブランチごとに変化するプロパティが含まれているため、それらを使用して検索/置換することはできません。考えられるすべての組み合わせを試しましたが、どこにも行きません。の文字列を検索/置換しようとする*と、引数リストが長すぎるというエラーが表示されます。空白行と 1 を検索/置換しようとすると*、それも検出されません。いくつかの例:

perl -pi -e 's/\n\*/<!--/g' */*/*.log 
perl -pi -e 's/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*/<!--/g' */*/*/log
perl -pi -e 's/>\n\*/><!--/'g */*/*.log (this one tries finding the end of the tag above it)

******************************************************

This system is for the use of authorized users only.
Individuals using this computer system without
authority, or in excess of their authority, are
subject to having all of their activities on this
system monitored and recorded by system personnel.

In the course of monitoring individuals improperly
using this system, or in the course of system
maintenance, the activities of authorized users may
also be monitored.

Anyone using this system expressly consents to such
monitoring and is advised that if such monitoring
reveals possible evidence of criminal activity, system
personnel may provide the evidence of such monitoring
to law enforcement officials.

******************************************************
4

2 に答える 2

0

フリップフロップ演算子はどうですか?

perl -ne 'print unless /^\*+/ ... /^\*+/'

perlopの範囲演算子を参照してください。

于 2012-05-31T16:58:27.763 に答える
0

複数の行にわたって一致できるように、ファイル全体を丸呑みします。

perl -i~ -0777pe's/^\*{54}\n.*?^\*{54}\n//m' file
于 2012-05-31T18:03:56.430 に答える