Note
This post is about parsing technique in Bash. If you have no idea what Bash is, then this is not the post for you.
If the following code is all you have done with Bash read builtin command, then you have missed a lot of fun!
read -p "Please enter your username: " username
Ever tried with -a, -n, or -t? At least, you have used -s (silent mode) for password input, right? I only used read to get user inputs. But someday, I found out it could be even more. Anyway, this post is about parsing, so those options are not the superstars today.
Contents
1 Example
Say you want to get the process ID, which uses the most CPU resource currently, as well as the percentages of CPU utilization and memory usage.
% ps -u $UID -o pid= -o %cpu=,%mem= --sort -%cpu | line 509 10.4 1.2