michaelsanford
Translator, Web Developer
I made a small one-liner to renice to +1 whatever application name I pass to the script. It uses grep to look through the output of ps -aux for the string I use as an argument.
The output:
The code:
So why is it doing it three times? After the script terminated I tried (ps -aux | grep 1818 | grep -v grep) and (ps -aux | grep 1807 | grep -v grep) and they both cae up empty, which leads me to believe that they are instances of grep. But I used the -v flag with grep, so why would they show up at all?
PS This is the second shell script I've ever written...
The output:
Code:
[gwailo:~/bin]% ./dumb MSN
Renicing MSN to 1
1818: old priority 0, new priority 1
1807: old priority 0, new priority 1
1541: old priority 1, new priority 1
Done
[gwailo:~/bin]% ps -aux | grep MSN | grep -v grep
gwailo 1541 0.7 1.4 100872 11024 ?? SN 10:09.45 /Applications/MSN Messenger/MS
The code:
Code:
echo "Renicing $1 to 1"
renice 1 `ps -aux | grep $1 | grep -v grep | awk '{print $2}'`
echo "Done"
So why is it doing it three times? After the script terminated I tried (ps -aux | grep 1818 | grep -v grep) and (ps -aux | grep 1807 | grep -v grep) and they both cae up empty, which leads me to believe that they are instances of grep. But I used the -v flag with grep, so why would they show up at all?
PS This is the second shell script I've ever written...