1

I am trying to get this output

  15%   abc
   7%   xyz

Running this command

ps axo pmem,args --sort  -pmem,-rss,-vsz | grep -v grep | 
                      grep  -e abc-e xyz | awk {'print $1'}

How can I fit my grep -e arguments inside the output?

Right now, predictably, I am only getting

15%
7%

You can assume that my Python script is creating the command on the fly and that I can modify it any way I need to.

3
  • Do you want to use that specific output for anything else? if not top/htop are pretty awesome Commented Nov 1, 2016 at 22:14
  • Basically, problem i am trying to find is a) find out what speficic apps are running as a given user (done), b) figure out whether box itself is running hot (done) and c) if box is running hot - are any of my apps (known) are responsible for it. What I need is to link ps output with app name Commented Nov 1, 2016 at 22:16
  • You've documented the expected output, could you put the input into the question also ? Might be possible to lose the greps and just do the matching within awk. Commented Nov 1, 2016 at 22:36

1 Answer 1

1

From the output example I think you need something like this:

ps axo pmem,args --sort -pmem,-rss,-vsz | awk '{print $1 "% " $2}' | grep -e abc -e xyz

Output should be:

15.0% abc
7.0% xyz

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.