[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: problemi con wget



On Sat, Feb 07, 2004 at 01:23:56PM +0100, MaX wrote:
[...]
> cosa mi dite invece del secondo problema?  magari faccio un post 

ale' questa e' la settimana del perl!

# cat test 
16:26:25 (192.92 KB/s)
 `sito.ftp.org/pub/file.tgz
 saved 353857

16:25:50 (271.44 KB/s)
 `sito.ftp.org/pub/file.tgz
 saved bytes 353892

# cat test | perl -e "while (<STDIN>) { \
  if ( m/^(.*?saved )(.*?)(\d+)\$/ ) { \
    print \$1 . sprintf(\"%.3f\", (\$3/(1024*1024))) . \" MB\n\"; \
  } else { \
    print; \
  } \
}"
16:26:25 (192.92 KB/s)
 `sito.ftp.org/pub/file.tgz
 saved 0.337 MB

16:25:50 (271.44 KB/s)
 `sito.ftp.org/pub/file.tgz
 saved 0.337 MB

ti riscrivo lo scriptino se vuoi farne un file:

-----8<-----8<-----8<-----8<-----8<-----

#!/usr/bin/perl

while (<STDIN>) { 
  if ( m/^(.*?saved )(.*?)(\d+)$/ ) { 
    print $1 . sprintf("%.3f", ($3/(1024*1024))) . " MB\n"; 
  } else { 
    print; 
  } 
}

-----8<-----8<-----8<-----8<-----8<-----

hth
-- 
mattia
:wq!
ante diem VII Idius Februarias MMDCCLVII ab Urbe Condida



Reply to: