[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
GNU Parallel Bug Reports Alpha release of GNU Parallel 20110505
From: |
Ole Tange |
Subject: |
GNU Parallel Bug Reports Alpha release of GNU Parallel 20110505 |
Date: |
Thu, 5 May 2011 22:51:49 +0200 |
The GNU Parallel 20110505 alpha release can be fetched at:
http://alpha.gnu.org/gnu/parallel/parallel-20110505.tar.bz2
Please test it thoroughly so we are sure nothing is broken.
So far GNU Parallel has been focused on replacing a single
for-loop. This alpha release introduces a way to replace nested
loops.
As example I will use the image manipulation program 'convert'. This
will convert foo.png to jpg with a size of 800 and JPEG-quality of 95.
convert -size 800 -quality 95 foo.png foo_800_q95.jpg
With a for-loop it can be done on a list of files:
time \
for file in *.png ; do
convert -size 800 -quality 95 $file ${file##.JPG}_800_q95.jpg
done
Using GNU Parallel it looks like this:
time parallel convert -size 800 -quality 95 {} {.}_800_q95.jpg ::: *.png
To get the images in 3 different JPEG-qualities you can use a nested for-loop:
time \
for qual in 25 50 95 ; do
for file in *.png ; do
convert -size 800 -quality $qual $file ${file##.JPG}_800_q${qual}.jpg
done
done
With GNU Parallel 20110505 you can do this:
time parallel convert -size 800 -quality 95 {1} {1.}_800_q{2}.jpg :::
*.png ::: 25 50 95
To get the 3 different JPEG-qualities in 2 different sizes you can use
a nest the for-loop even further:
time \
for size in 800 30 ; do
for qual in 25 50 95 ; do
for file in *.png ; do
convert -size $size -quality $qual $file
${file##.JPG}_${size}_q${qual}.jpg
done
done
done
With GNU Parallel 20110505 you can do this:
time parallel convert -size {3} -quality {2} {1} {1.}_{3}_q{2}.jpg :::
*.png ::: 25 50 95 ::: 800 30
You can also provide the arguments in a file. This will do the same as above:
(echo 25; echo 50; echo 95) > qualities
ls *.png > png-files
(echo 800; echo 30) > sizes
time parallel convert -size {3} -quality {2} {1} {1.}_{3}_q{2}.jpg
:::: png-files qualities sizes
It is also possible to mix triple and quad colon. These will do the
same as above:
time parallel convert -size {3} -quality {2} {1} {1.}_{3}_q{2}.jpg
:::: png-files ::: 25 50 95 ::: 800 30
time parallel convert -size {3} -quality {2} {1} {1.}_{3}_q{2}.jpg
:::: png-files ::: 25 50 95 :::: sizes
The special file '-' reads from standard input. This will do the same as above:
ls *.png | time parallel convert -size {3} -quality {2} {1}
{1.}_{3}_q{2}.jpg :::: - ::: 25 50 95 :::: sizes
Please download
http://alpha.gnu.org/gnu/parallel/parallel-20110505.tar.bz2 and test
it thoroughly so we are sure nothing is broken.
/Ole
- GNU Parallel Bug Reports Alpha release of GNU Parallel 20110505,
Ole Tange <=