Is there a way to restrict the output of, say ps aux | grep word, so that each process is displayed on a separate single line?

I need this, because my processes descriptions take up a lot of lines and I don't have good visibility when listing them with the above command. I would be happy to see just the first line of each process' representation.

  • 2
    Configure your terminal to not wrap lines or cut the lines manually. Commented Dec 20, 2017 at 9:55

3 Answers 3


Actually, each process is already displayed on a single line, that's why grep shows that much info.

If you are willing to sacrifice the amount of details that the "COMMAND" column of ps aux offers, you may trim the output as such:

ps aux | awk '/word/ {print $1"\t"$2"\t"$3"\t"$4"\t"$9"\t"$11}'

The awk looks for lines containing pattern 'word' and prints:

the USER, PID, %CPU, %MEM, START and first string (delimited by space)from the COMMAND column, all separated by TAB('\t')


You may find the pstree command useful. It lists all processes as a tree diagram.

  • This is for sure a very useful command, thanks for sharing it. Unfortunately, my java processes seem to be listed as a single line ├─java───98*[{java}] under systemd . I will definitely use it, though.
    – Mateva
    Commented Dec 20, 2017 at 9:55

When ps aux output is directed to a terminal, the command limits the command part to the width of the screen.

When the output is piped to a command, the behavior vary but usually, the width is unlimited. If you want to limit it the same way, you can use that command:

ps aux --witdh ${COLUMNS:-80} | grep word

Of course, if word isn't in the displayed characters but in the truncated ones, this won't fly.

Here are a couple of alternatives:

ps aux | awk '/word/ {print substr($0,1,'${COLUMNS:-80}')}'

ps -up $(pgrep -f word|tr '\n' ','| sed 's/,$//') 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .