Skip to main content

Solaris ps aux command specific output. Why do need the `ww` flags to find matches with grep? [Resolved]

I'm starting to use Oracle Solaris 11.2 SPARC.

In Linux, I can write

ps aux | grep *some_data*

... but that doesn't show any result on Solaris.

Instead I need to say

ps auxww | grep *some_data* 

I had a look at man ps to find more information about ww

If the option letter is repeated, that is, -ww, this option uses arbitrarily wide output

Why do I need to use ww to get anything to grep?


Question Credit: P.Grjozs
Question Reference
Asked March 10, 2018
Tags: grep, solaris
Posted Under: Unix Linux
56 views
2 Answers

You are using non standard BSD options, whether under Linux or Solaris.

The portable way is to use the -o option to specify which fields you want to appear, here for example ps -o pid,args. Note that unless you are using a recent 11.3 update or newer, the argument list will be limited to 80 characters unless you are root or own the process.

Alternatively, you might use pgrep -f which will search for the full command line.


credit: jlliagre
Answered March 10, 2018

On Linux the ps command detects whether the output is to a terminal or not. If it is to a terminal then it truncates the output to the terminal width. If it is not on a terminal then it doesn't truncate. Effectively it behaves as if it automatically adds the ww flags.

You can see the difference by typing ps aux and ps aux | cat

In your example you are piping the output to grep and so it acts as if you typed ps auxww | grep.

For portability you should always use the ww flags if you want to see all the data beyond (say) 80 characters.

Note: you're using the BSD form of the ps command, so on Solaris make sure you're calling the right one!


credit: Stephen Harris
Answered March 10, 2018
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA