複数のファイルからパターンを削除する方法

複数のファイルからパターンを削除する方法

次の情報を含むデータファイルがあります。

977.txt:[email protected]
977.txt:[email protected]
980.txt:[email protected]
982.txt:[email protected]
985.txt:[email protected]
987.txt:[email protected]
987.txt:[email protected]
991.txt:[email protected]
991.txt:[email protected]
991.txt:[email protected]
994.txt:[email protected]
995.txt:[email protected]
999.txt:[email protected]

以前にすべてを削除したい:ディレクトリ内のすべてのファイルに対してこれを行う方法(Linux)。

私はこれを試しましたが、うまくいきますが、複数のファイルには使用できません。

grep -o - '[[:alnum:]+\._\-]*@[[:alnum:]+\._\-]*' file.txt

ベストアンサー1

別のsed解決策。

$ sed -n 's/[^:]*\://p' infile
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
$

-iディレクトリツリーでファイルを内部編集および再帰的に編集するために、そのオプションを使用するように簡単に拡張できます。find

おすすめ記事