在像以下文件中:
build.gradle
dependencies {
runtime module("org.codehaus.groovy:groovy:2.4.4") {
dependency("commons-cli:commons-cli:1.0") {
transitive = false
}
module(group: 'org.apache.ant', name: 'ant', version: '1.9.6') {
dependencies "org.apache.ant:ant-launcher:1.9.6@jar",
"org.apache.ant:ant-junit:1.9.6"
}
}
}
我如何grep包含oneA twoA threeA
oneB twoB threeB
oneC threeC
oneA twoD threeA
但未跟two
的所有行?
即
A
答案 0 :(得分:0)
#grep line containing two and exclude which has twoA
grep two filename.txt |grep -v twoA
oneB twoB threeB
oneA twoD threeA
使用Awk:
awk '!/twoA/ && /two/' filename.txt
oneB twoB threeB
oneA twoD threeA
答案 1 :(得分:0)
请说:
$ grep 'two[^A]' file
oneB twoB threeB
oneA twoD threeA
即grep
two
后跟A
以外的任何字符。