I explain my problem on Ubuntu 16.04 with the following example: The file is:
# cat file
aaa
aaaxxx
aaaxxx*aaa
aaa=aaaxxx
bbbaaaccc
aaaddd/aaaxxx
I want to display all lines which contain aaa
but not in the only combination of aaaxxx
. I want an output like this:
# grep SOMETHING-HERE file …
aaa
aaaxxx*aaa (second aaa is the hit)
aaa=aaaxxx (first aaa is the hit)
bbbaaaccc (aaa in any other combination but not aaaxxx)
aaaddd/aaaxxx (similar to above)
I tried things like grep -v aaaxxx file | grep aaa
which results:
aaa
bbbaaaccc
or
# egrep -P '(?<!aaaxxx )aaa' file
grep: die angegebenen Suchmuster stehen in Konflikt zueinander (the pattern are in contradiction)
Is there any (simple) possibility? Of course it doesn’t need to be grep
.
Thanks
aaaxxx
" - don't you mean exceptaaaxxx
?aaa
followed by anything exceptxxx
?not
. I updated the questionaaaxxx
. However I want lines withaaa
andaaaxxx
. Puh!aaa
, including those matchingaaaxxx
but not lines that have onlyaaaxxx
. So,aaa
is fine,aaaxxxfoo
is fine, butaaaxxx
alone should be skipped?