[ubuntu-us-mn] Scaling a number string in Sed?
Tony Yarusso
tonyyarusso at gmail.com
Fri Feb 8 00:31:09 UTC 2013
On Thu, Feb 7, 2013 at 12:59 PM, Fred H Olson <fholson at cohousing.org> wrote:
> Anyone know whether Sed can be used to convert the last line of Wget
> output (first line of exmple below) to something like the second line.
No. It can do the rearranging of parts, but not the math.
> That is to scale the KB/s to Mb/s (multiply by .008) ?
Careful - you have two different things here. There's a download
speed in KB/s and a file size in MB - they are not both per second.
> Or another way to do it?
> Anyone care to take a stab at it?
Here's what I cobbled together with a mixture of a small shell script
to do various sed bits and a long python script to do the math stuff.
In action it looks like this:
winisk:tmp yarusso$ ./fetch.sh
http://cdimage.debian.org/debian-cd/6.0.6/i386/iso-cd/debian-6.0.6-i386-businesscard.iso
2013-02-07 18:26:43 (46.0MB at 12.24Mb/s) -
‘debian-6.0.6-i386-businesscard.iso’ saved
There are probably several bugs still lurking in there, so feel free
to let me know if you find some. I'm also not going to claim this is
the most efficient way - so feel free to offer your alternatives too.
:)
- Tony Yarusso
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fetch.sh
Type: application/x-sh
Size: 516 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-us-mn/attachments/20130207/23fd9866/attachment.sh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bitconvert.py
Type: application/octet-stream
Size: 6828 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/ubuntu-us-mn/attachments/20130207/23fd9866/attachment.obj>
More information about the ubuntu-us-mn
mailing list