如何在文件中排除所有包含日期​​或括号的行

How to exclude in file all rows which contains date or brackets

如何在文件中排除所有包含日期​​和括号的行

就我而言:

2015-01-16 12:51:34,787 | [D] | query.Selao | ref:5463| 13 | Selao .select | Binding 4 to 432| [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'
java.lang.NullPointerException
        at com.api.base.dataaccess.elen(elen.java:424)
2015-01-16 12:51:34,788 | [D] | query.Selao | ref:5464| 14 | Selao .select | Binding 5 to 433| [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'
   <list>
    <Filters class="com.base.Filter">
     <Negated value="false"/>
    </Filters>
   </list>

排除后预期:

java.lang.NullPointerException
        at com.api.base.dataaccess.elen(elen.java:424)

使用awk,

$ awk '!/[0-9]{4}-[0-9]{2}-[0-9]{2}|<.*>/' file
java.lang.NullPointerException
        at com.api.base.dataaccess.elen(elen.java:424)

grep -v '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\|<.*>' file
egrep -v '([0-9]{4}(-[0-9]{2}){2})|(\[.*\])' YourFile

但是 post 中的 <LIST> 呢?没有日期也没有括号但不在预期输出中?

如果括号不是[]而是<>

egrep -v '([0-9]{4}(-[0-9]{2}){2})|(<.*>)' YourFile

所有 3

egrep -v '([0-9]{4}(-[0-9]{2}){2})|(<.*>)|(\[.*\])' YourFile

删除所有包含特定模式的行的 sed 解决方案如何:

sed '/20[0-9][0-9]-[0-9]/d;/\<.*\>/d' file