سؤال

# spam.txt
src/blahblah/potato.py
src/migrations/helloworld.py
spam/blahblah/thing.py
src/thingy/other.cpp

I have this:

$ cat spam.txt | grep 'src.*\.py' | grep --invert-match '/migrations/'
src/blahblah/potato.py

How can I chain the exclude into the same pattern? i.e. how can I write the 'pattern???' below so that I get the same result?

$ grep 'pattern???' spam.txt
هل كانت مفيدة؟

المحلول

Better

awk '/src/ && /\.py/ && ! /migrations/' spam.txt

Example

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top