Question

# 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
Was it helpful?

Solution

Better

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

Example

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top