parallel: --block support both base 2 and base 10: k=1000, K=1024, Ki=1024.

This commit is contained in:
Ole Tange 2011-08-03 11:54:55 +02:00
parent 3a7097684c
commit 207f8dfabc
2 changed files with 19 additions and 4 deletions

View file

@ -1741,8 +1741,22 @@ sub usleep {
sub multiply_binary_prefix {
# Evalualte numbers with binary prefix
# k=10^3, m=10^6, g=10^9, t=10^12, p=10^15, e=10^18, z=10^21, y=10^24
# K=2^10, M=2^20, G=2^30, T=2^40, P=2^50, E=2^70, Z=2^80, Y=2^80
# Ki=2^10, Mi=2^20, Gi=2^30, Ti=2^40, Pi=2^50, Ei=2^70, Zi=2^80, Yi=2^80
# ki=2^10, mi=2^20, gi=2^30, ti=2^40, pi=2^50, ei=2^70, zi=2^80, yi=2^80
# 13G = 13*1024*1024*1024 = 13958643712
my $s = shift;
$s =~ s/k/*1000/g;
$s =~ s/M/*1000*1000/g;
$s =~ s/G/*1000*1000*1000/g;
$s =~ s/T/*1000*1000*1000*1000/g;
$s =~ s/P/*1000*1000*1000*1000*1000/g;
$s =~ s/E/*1000*1000*1000*1000*1000*1000/g;
$s =~ s/Z/*1000*1000*1000*1000*1000*1000*1000/g;
$s =~ s/Y/*1000*1000*1000*1000*1000*1000*1000*1000/g;
$s =~ s/X/*1000*1000*1000*1000*1000*1000*1000*1000*1000/g;
$s =~ s/Ki?/*1024/gi;
$s =~ s/Mi?/*1024*1024/gi;
$s =~ s/Gi?/*1024*1024*1024/gi;

View file

@ -331,9 +331,10 @@ Implies B<--semaphore>.
=item B<--block-size> I<size>
Size of block in bytes. The size can be postfixed with K, M, G, T, or
P which would multiply the size with 1024, 1048576, 1073741824,
1099511627776 or 1125899906842624 respectively.
Size of block in bytes. The size can be postfixed with K, M, G, T, P,
k, m, g, t, or p which would multiply the size with 1024, 1048576,
1073741824, 1099511627776, 1125899906842624, 1000, 1000000,
1000000000, 1000000000000, or 1000000000000000 respectively.
GNU B<parallel> tries to meet the block size but can be off by the
length of one record.
@ -799,7 +800,7 @@ B<tr ':' '\012' < /etc/passwd | parallel -N7 chown {1} {6}>
Implies B<-X> unless B<-m> or B<--pipe> is set.
When used with B<--pipe> B<-N> is the number of records to read. This
is much slower than B<--blocksize> so avoid it if performance is
is much slower than B<--block> so avoid it if performance is
important.