문제

# 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