I'm using macOS Sierra and I would like to log a process with the top command and store all the information in a file. I'm using the following command:top | grep --line-buffered PROCESS > test.txtThis perfectly works, but I would like to select only certain columns as the reseults:PIDMemory UsageCPU UsageNetwork UsageDisk UsageIs there a way to filter the top result and select only the columns of my interest?
filter top result
text processing;command line;grep;top
You can run this command in a loop.top -l 1 | grep PROCESS | awk '{print $1,$2}' >> test.txtUse awk to select the respective columns you want to include in your logs. For example, $1 is the first column, $2 is the second and so on.