如何删除与 Perl 中某个模式匹配的行? [英] How to delete lines matching a certain pattern in Perl?
本文介绍了如何删除与 Perl 中某个模式匹配的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做一些类似于 Perl 中的 sed
的事情,即能够删除匹配特定模式的行.
I'd like to do something similar to sed
in Perl, namely be able to delete lines matching a certain pattern.
鉴于此输入:
abcd
edfd
abcd
derder
abcd
erre
我想删除包含 bc
的行.我该怎么做?
I want to remove the lines containing bc
. How can I do this?
推荐答案
我不得不在 Windows 上使用双引号:
I had to use double quotes on Windows:
perl -ne "print unless /bc/" file
这篇关于如何删除与 Perl 中某个模式匹配的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文