I'm trying to learn some more Linux, and from experience the best way is to try to bang your head against the wall. So now that I've done a task manually a few times I would like to automate it. This involves making a oneliner to kill some tasks so I can restart them.
At the moment I'm working with the following:
for i in `ps aux | egrep "[c]ouchpotato|[s]abnzbd|[s]ickbeard|[d]eluge|[n]zbhydra"|awk '{print $2, $11, $12}'`; do echo $i; done
The thing is that as soon as I run the for loop it breaks up the lines I get from awk.
Running
ps aux | egrep "[c]ouchpotato|[s]abnzbd|[s]ickbeard|[d]eluge|[n]zbhydra"|awk '{print $2, $11, $12}'
gives me the result I'm looking for, namely:
27491 /usr/local/couchpotatoserver-custom/env/bin/python /usr/local/couchpotatoserver-custom/var/CouchPotatoServer/CouchPotato.py
27504 /usr/local/deluge/env/bin/python /usr/local/deluge/env/bin/deluged
27525 /usr/local/deluge/env/bin/python /usr/local/deluge/env/bin/deluge-web
27637 /usr/local/nzbhydra/env/bin/python /usr/local/nzbhydra/share/nzbhydra/nzbhydra.py
27671 /usr/local/sabnzbd/env/bin/python /usr/local/sabnzbd/share/SABnzbd /SABnzbd.py
28084 /usr/local/sickbeard-custom/env/bin/python /usr/local/sickbeard-custom/var/SickBeard/SickBeard.py
But adding it to my for loop breaks it into:
27491
/usr/local/couchpotatoserver-custom/env/bin/python
/usr/local/couchpotatoserver-custom/var/CouchPotatoServer/CouchPotato.py
27504
/usr/local/deluge/env/bin/python
/usr/local/deluge/env/bin/deluged
etc...
My goal is for $i to contain the whole line - is this possible? Also, is it possible to use get only the command from $11 and $12? I don't need to have the whole path to python and I don't even need to have the whole path to the application.
Thanks!