My objective (read Homework) is to find the process that is consuming the most CPU and RAM by writing a script. I've managed to extract the info from TOP command however I'm having trouble parsing the output.
The following command
top -b -n 1 | tail -n +8 | head -n 1
will output something similar to this single line
915 root 20 0 209m 74m 8644 S 8 7.7 5:27.57 Xorg
I want this line of text to be the argument list for my script. I realize that I have to read it from the STDIN but
I want to read the above output word by word or argument by argument ,as if it was given from the command line.
echo " Parameter is ${2} ${3}"