|
The question about OS is not really well-defined. Probably uname -o is sufficient, yes. It is customary if somebody asks to include more or less all of uname -a
uname -n prints the system's name, so you don't have to use awk for that. grep is not really the right tool for this (although it could probably be done).
Generally a well-designed Unix tool will have an option to generate output in a form which is useful for scripting. Unfortunately, not nearly all system utilities are well-designed by this criterion. (ls comes to mind, and, oh, ifconfig.)
This message box is too small for a good awk tutorial (and I'm not the right person to write that) but a general pattern is awk '/text which is unique for the line you want/ { print $n }' where n is the field number (space-separated, starting from 1) on that line. There are various facilities for using something other than spaces as separators, and, well, awk is a Turing-complete programming language, so your imagination is really the only limit.
|