I have written a command to retrieve a process having maximum CPU% using ps and sort in combination. This command retrieves the first result of the list, and to be more specific I just want the pid of that topmost process. What modifications do I need to do in the command so that it would return the pid of that topmost result and how to store it?
$ ps aux --sort -%cpu | tail -n +2 | head -1
sharwari 2831 14.9 25.9 1725720 976104 ? Sl 21:25 20:03 /usr/lib/firefox/firefox