Reputation: 6939
I came across the following sed command which I found here https://github.com/shama/grunt-hub:
ps -ef | sed -n '/grunt/{/grep/!p;}'
Could someone explain me how does the sed
part work? What's the purpose of {/grep/!p;}
?
Thanks for the attention!
Upvotes: 1
Views: 152
Reputation: 18381
compare the output of following two commands:
ps -ef | sed -n '/grunt/p'
and ps -ef | sed -n '/grunt/{/grep/!p;}'
.
You will notice later is not printing one additional like which contains process id of the grep command you hit. This would be equivalent to:
ps -ef |grep grunt |grep -v grep
Its like print all the lines containing grunt but not the line also containing grep in it
Upvotes: 2