Joined: Feb. 2006
||Posted: Jan. 29 2008,18:23
|Quote (^thehatsrule^ @ Jan. 29 2008,14:29)|
I'd stick with sed because it should be a 'lighter' binary (unless you have some reason to worry about having a missing sed)
|I would also like to replace sed with awk if it can perform search & replace easily, like sed.|
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.
Yes. Just because of that. I've read that awk is more common than sed.
|A version of the AWK language is a standard feature of nearly every modern Unix-like operating system available today.|
|Besides the Bourne shell, AWK is the only other scripting language available in a standard Unix environment.|
But now when you said that sed is lighter, I'll plan my script primary to look for sed, and then awk. =)
I think I have to stick with multiple cases. If I pass OUTPUT_FORMAT for for -loop to go trough and
then if/when sed/awk modifies it (still insife for -loop), for -loop won't know it's been modified. Right?
Then case inside for -loop might have to modify same information, bit in different place (in OUTPUT_FORMAT), more than once. Ok. Cituation like this is rare.Possible only is user has specified same spot (-UPTIME- for example) more than once.
With many case -sentences OUTPUT_FORMAT is modified instantly if any of the case -sentences is triggered.
Anyway tests that I performed showed very little difference, so I think this "performance tweaking" with for-case vs. many cases isn't really relevant anymore. I'd like to focus more to make this script to work on as many platforms/OSes as possible, meaning to make this use most common UNIX tools awailable.. ;) Many thanks anyway.
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.
Get it? ;)
Ok. Enough long post already. Brb going to moon.
Do you have it? - http://dy.fi/mak