如何反转grep表达式 [英] How to invert a grep expression
本文介绍了如何反转grep表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下grep表达式成功列出当前目录和子目录中的所有.exe和.html文件。
The following grep expression successfully lists all the .exe and .html files in the current directory and sub directories.
ls -R |grep -E .*[\.exe]$\|.*[\.html]$
如何反转此结果以列出那些不是.html或.exe的文件代替。 (即!=
。)
How do I invert this result to list those that aren't a .html or .exe instead. (That is, !=
.)
推荐答案
使用命令行选项 -v
或 - 反向匹配
,
ls -R |grep -v -E .*[\.exe]$\|.*[\.html]$
这篇关于如何反转grep表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文