Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
Why are you using echo here at all? –  Michael Hampton Dec 18 '13 at 20:33
Michael is correct, your use of echo with no double quotes is the root cause of your whitespace problems. –  glenn jackman Dec 18 '13 at 20:33
At this point, I am pretty much a copy and paste admin, so I found that online. I tried taking it out of the echo and my output was NULL (I think I got that from ) –  TecBrat Dec 18 '13 at 20:34
I tried it again. I must have made a mistake when I pulled it out of the echo before. When I just did ps -ewwo args | grep -n '^[^ ]*curl' it worked –  TecBrat Dec 18 '13 at 20:38
Mickael, If you'll make that an answer, I'll give you credit for it. –  TecBrat Dec 18 '13 at 20:39

1 Answer 1

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 using echo at all, for example:

ps -ewwo args | grep '^[^ ]*curl'
ps -ewwo args | grep -n '^[^ ]*curl'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.