Page 1 of 1
Sed help (for bash scripting)
Posted: 2003-03-05 01:48am
by Pu-239
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?
Re: Sed help (for bash scripting)
Posted: 2003-03-05 01:52am
by Darth Wong
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?
Try using awk instead of sed.
Posted: 2003-03-05 02:02am
by Pu-239
ok, I'll try tommorrow.
Re: Sed help (for bash scripting)
Posted: 2003-03-05 10:10am
by BoredShirtless
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?
I'd like to answer your question, but I don't want to deprive you of doing your own homework
Posted: 2003-03-05 10:39am
by Crazy_Vasey
It would be a great deal easier to do that in python.