[Android Software/Hacking General [Developers Only]] gu5t3r:
We are not on same page here... It should be the same but it is NOT...

With your check you are relaying on that it will be at least one hit, the grep itself...

WHAT I'm trying to explain you is that in 20% of case, grep does not catch itself...

root@android:/data/V6_SuperCharger # ps -w | grep Fast
7230 root 668 S {!FastEngineFlus} /system/bin/sh /data/V6_SuperCharger/!FastEngineFlush.sh
10577 root 1204 S grep Fast
root@android:/data/V6_SuperCharger # ps -w | grep Fast
7230 root 668 S {!FastEngineFlus} /system/bin/sh /data/V6_SuperCharger/!FastEngineFlush.sh
10585 root 1204 S grep Fast
root@android:/data/V6_SuperCharger # ps -w | grep Fast
7230 root 668 S {!FastEngineFlus} /system/bin/sh /data/V6_SuperCharger/!FastEngineFlush.sh
10598 root 1204 S grep Fast
root@android:/data/V6_SuperCharger # ps -w | grep Fast
7230 root 668 S {!FastEngineFlus} /system/bin/sh /data/V6_SuperCharger/!FastEngineFlush.sh
10601 root 1204 S grep Fast
root@android:/data/V6_SuperCharger # ps -w | grep Fast
7230 root 668 S {!FastEngineFlus} /system/bin/sh /data/V6_SuperCharger/!FastEngineFlush.sh
root@android:/data/V6_SuperCharger # ps -w | grep Fast
7230 root 668 S {!FastEngineFlus} /system/bin/sh /data/V6_SuperCharger/!FastEngineFlush.sh
10619 root 1204 S grep Fast
root@android:/data/V6_SuperCharger # ps -w | grep Fast
7230 root 668 S {!FastEngineFlus} /system/bin/sh /data/V6_SuperCharger/!FastEngineFlush.sh
10622 root 1204 S grep Fast
root@android:/data/V6_SuperCharger # ps -w | grep Fast
7230 root 668 S {!FastEngineFlus} /system/bin/sh /data/V6_SuperCharger/!FastEngineFlush.sh
root@android:/data/V6_SuperCharger #

If I do "ps -w | grep Fast" you are relaying on that it will be at least one hit "grep Fast", but as you can see sometimes grep Fast does not catch "grep Fast"...With grep -v grep you are always eliminating grep, so it does no matter then it caches itself or not...

Result was the same for running script with or without sh, because when run with sh it adds extra hit, shows the script on check as two process (shows two pids)...

"grep -c blah" counts the lines that have blah, and outputs the number of that liines ([0,infinity>). It is the same as "grep blah | wc -l", grep returns lines with blah and then wc counts it....

"grep -vc blah" counts the lines without blah, it is the same as "grep -v blah | wc -l"

BUT in "grep blah | grep -vc grep", "grep blah" counts the lines with blah (in that lines sometimes there is grep blah, and sometimes it is NOT) and pipes it to "grep -vc grep" which count all lines from "grep blah" without grep, that way it does not matter if grep will see itself in ps -w or not because it will never be counted!

And why use wc if you don't need it...

For

busybox ps | grep Matic_is_In_Effect | grep -vc "grep Matic_is_In_Effect"

check you don't grep -vc grep because you are outputting In effect message with grep, that is why you are doing grep -vc "grep Matic_is_In_Effect" to eliminate grep hit itself because sometimes it does, sometimes it does NOT

or you can do

busybox ps | grep Matic_is_In_Effect | grep -vc grep\ Matic_is_In_Effect

It looks better without quotes...

This way you will always get same result, because you are not counting grep itself

root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
1
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
1
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
1
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
1
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger # ps -w | grep Matic | wc -l; ps -w | grep Matic | grep -vc grep\ Matic
2
1
root@android:/data/V6_SuperCharger #

The way with grep -vc is consistent, your way is not...

Huh...my fingers hurt... =)