I'm trying to remove everything after the first number with sed in this sequence:
0.89 0.77 0.73 2/47 1601 (from /proc/loadavg) then turn it into a whole number for use in a script.
cat /proc/loadavg|sed s/?.??//2|sed s/?.??//2|sed s/*\/*// doesn't work.
And how do you multiply or round numbers in a shell script?
Sed help (for bash scripting)
Moderator: Edi
Sed help (for bash scripting)
ah.....the path to happiness is revision of dreams and not fulfillment... -SWPIGWANG
Sufficient Googling is indistinguishable from knowledge -somebody
Anything worth the cost of a missile, which can be located on the battlefield, will be shot at with missiles. If the US military is involved, then things, which are not worth the cost if a missile will also be shot at with missiles. -Sea Skimmer
George Bush makes freedom sound like a giant robot that breaks down a lot. -Darth Raptor
- Darth Wong
- Sith Lord
- Posts: 70028
- Joined: 2002-07-03 12:25am
- Location: Toronto, Canada
- Contact:
Re: Sed help (for bash scripting)
Try using awk instead of sed.Pu-239 wrote:I'm trying to remove everything after the first number with sed in this sequence:
0.89 0.77 0.73 2/47 1601 (from /proc/loadavg) then turn it into a whole number for use in a script.
cat /proc/loadavg|sed s/?.??//2|sed s/?.??//2|sed s/*\/*// doesn't work.
And how do you multiply or round numbers in a shell script?
"It's not evil for God to do it. Or for someone to do it at God's command."- Jonathan Boyd on baby-killing
"you guys are fascinated with the use of those "rules of logic" to the extent that you don't really want to discussus anything."- GC
"I do not believe Russian Roulette is a stupid act" - Embracer of Darkness
"Viagra commercials appear to save lives" - tharkûn on US health care.
http://www.stardestroyer.net/Mike/RantMode/Blurbs.html
"you guys are fascinated with the use of those "rules of logic" to the extent that you don't really want to discussus anything."- GC
"I do not believe Russian Roulette is a stupid act" - Embracer of Darkness
"Viagra commercials appear to save lives" - tharkûn on US health care.
http://www.stardestroyer.net/Mike/RantMode/Blurbs.html
ok, I'll try tommorrow.
ah.....the path to happiness is revision of dreams and not fulfillment... -SWPIGWANG
Sufficient Googling is indistinguishable from knowledge -somebody
Anything worth the cost of a missile, which can be located on the battlefield, will be shot at with missiles. If the US military is involved, then things, which are not worth the cost if a missile will also be shot at with missiles. -Sea Skimmer
George Bush makes freedom sound like a giant robot that breaks down a lot. -Darth Raptor
- BoredShirtless
- BANNED
- Posts: 3107
- Joined: 2003-02-26 10:57am
- Location: Stuttgart, Germany
Re: Sed help (for bash scripting)
I'd like to answer your question, but I don't want to deprive you of doing your own homeworkPu-239 wrote:I'm trying to remove everything after the first number with sed in this sequence:
0.89 0.77 0.73 2/47 1601 (from /proc/loadavg) then turn it into a whole number for use in a script.
cat /proc/loadavg|sed s/?.??//2|sed s/?.??//2|sed s/*\/*// doesn't work.
And how do you multiply or round numbers in a shell script?
-
- Jedi Council Member
- Posts: 1571
- Joined: 2002-07-13 12:56pm