문제

The title says it all. I've seen this idiom used alot instead of adding an additional grep -v grep in some ps pipeline. For example it could be used like this:

$ ps aux | grep '[f]irefox' | awk '{ print $8 }'

instead of

$ ps aux | grep 'firefox' | grep -v grep | awk '{ print $8 }'

It's super-convenient, but how does it work and why?

도움이 되었습니까?

해결책

The pattern [f]irefox will not match the literal string [f]irefox. Instead it will match strings with exactly one char from the 1-character class [f], followed by irefox.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top