I need to occasionally monitor a spider that I have running on my server. I'm testing it to see how many iterations of it are running concurrently and to see if any of them are hanging.
I use this:
echo `ps -ewwo args | grep '^[^ ]*curl'`
and the output is all in one line. If I change that to
echo `ps -ewwo args | grep -n '^[^ ]*curl'`
I get the line numbers, but the output is still all in one line. How do I get it to break the results into separate lines?
As a test, I did something like
grep "br" /home/user/www/index.php
and it found many instances and output them each on a separate line, just like I want I to.
Best Answer
If you don't quote the output of a
`...`
subshell, the linebreaks will be replaced with spaces. If you want the linebreaks then don't use a`...`
subshell, just run the commands and let them do the outputting by themselves, without usingecho
at all, for example: