Quote (^thehatsrule^ @ Jan. 29 2008,14:29) | ||
Also, if you can, avoid using search and replace at all if possible. For example, looking at your code in your first post, you can make a function that can print the output from variables instead of replacing the text in OUTPUT_FORMAT. |
Quote |
A version of the AWK language is a standard feature of nearly every modern Unix-like operating system available today. |
Quote |
Besides the Bourne shell, AWK is the only other scripting language available in a standard Unix environment. |
Quote |
And I will need the search and replace because user running this script can specify his/her own output from the command line ie: ./sysinfo.sh "Uptime: -UPTIME- | Free RAM: -MEMFREE-" Basically sed (maybe awk also) is there to search & replace user defined command line arguments. |
Code Sample |
function parsememinfo { # Get memory information if there isn't already if [ -z "$MEMINFO" ] then MEMINFO=`cat /proc/meminfo` fi PARSED=${MEMINFO#*$*:} PARSED=${PARSED%% kB*} echo $PARSED } |