

Java being Java, it often does things in the worst possible way, so you some java services will run past the maximum allowed length of arguments that the process table will keep track of. This adds the column headers from ps, provides a more custom ps format that suits my needs betters, and displays processes listing extra, extra wide so that none of the command-line arguments are missed.

Here, I make some allowance for differences between Linux, OS X BSD, and others.

#Ps ef grep command in unix portable#
So you could write a portable psgrep command as follows. Since the search pattern to exclude a square bracket actually adds the square bracket to the pattern then it will never match itself. This variation says show the lines where the pattern matches WITHOUT a leading right-square-bracket ]. String slicing in Bash is an ugly thing, so my variation avoids that. When scripting in shell it's easier to simply stick ] in front of the pattern you were lookginfor looking for. You don't need to strip off the first letter of the string then insert it between the square braces and then concatenate the that back together again. The main advantage is that it's easier to write scripts based on this patterns because you simply concatenate a static string ] with whatever pattern you are looking for. Instead I use this pattern: $ ps -A -ww | grep ]foobar The typical answer looks like this: $ ps -A -ww | grep oobar The argument of "-A" "ps" is more portable than "aux", I believe, but this change is irrelevant to the answer. My answer is a variation on the typical answer for searching for "foobar" in a ps listing.
