You are taking the full result of ps in a single string, checking if there is a match and then printing the entire string. This results in printing the entire result if there is at least a match.
What you want to do is to split the string in an array of lines and then check & print each of them.
Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."
In reply to Re: Retrieve "ps -ef" strings using regex
by psini
in thread Retrieve "ps -ef" strings using regex
by Raoul
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |