So I’ve been trying to run the following command to check the consumption by the firefox process.
top -b | grep "firefox"
Now I can see the desired output in terminal for it. But now when I try to export it to a file, I’m not able to.
The command I’m running is:
top -b | grep "firefox" >> filename
or top -b | grep "firefox" > filename
Please help.
2
Answers
You need the
-n
parm fortop
. For example,Without
-n 1
top
will keep processing and will never make it togrep
..From the man page for
top
:Updated code with a
while
loop. It will loop forever unless you usesomething like
cntr
variable. Remove thecntr
code if you wantcontinuous monitoring:
You have to add in the command the flag -n
Change the number of processes to show. You will be prompted to enter the number.
To take a snapshot of a specific process in top utility, execute command with the PID (-p) flag.