parallel: - as argfile will read from stdin

This commit is contained in:
Ole Tange 2011-05-04 20:55:01 +02:00
parent 48199a88fe
commit 7f731a54b7
4 changed files with 45 additions and 6 deletions

View file

@ -1,3 +1,17 @@
parallel echo {1} {2} {3} ::: a b c :::: myfile ::: X Y
parallel oggenc -q {1} {2} {2.}_{1}.ogg ::: 1 5 10 :::: wavfiles
or
parallel oggenc -q {1} {2} {2.}_{1}.ogg ::: 1 5 10 ::: *.wav
or
ls *.wav | parallel oggenc -q {1} {2} {2.}_{1}.ogg ::: 1 5 10 :::: -
Postkort: Postkort:
- Forside kun figur - Forside kun figur
- Bagside: - Bagside:

View file

@ -179,6 +179,12 @@ New in this release:
* Robert from Echo One discusses using processes instead of threads: * Robert from Echo One discusses using processes instead of threads:
http://rrees.wordpress.com/2011/04/25/many-cores-many-threads/ http://rrees.wordpress.com/2011/04/25/many-cores-many-threads/
* How to run GNU Parallel on a SLURM cluster. Thanks to Kevin Stock.
http://www.kevinstock.org/2011/04/using-the-ri-cluster/
* Short article about using GNU Parallel with lame:
http://loopkid.net/articles/2011/04/30/accelerate-lame-mp3-conversion
* Bug fixes and man page updates. * Bug fixes and man page updates.

View file

@ -357,6 +357,7 @@ sub get_options_from_array {
"block|block-size|blocksize=s" => \$::opt_blocksize, "block|block-size|blocksize=s" => \$::opt_blocksize,
"tollef" => \$::opt_tollef, "tollef" => \$::opt_tollef,
"gnu" => \$::opt_gnu, "gnu" => \$::opt_gnu,
"xapply" => \$::opt_xapply,
# xargs-compatibility - implemented, man, testsuite # xargs-compatibility - implemented, man, testsuite
"max-procs|P=s" => \$::opt_P, "max-procs|P=s" => \$::opt_P,
"delimiter|d=s" => \$::opt_d, "delimiter|d=s" => \$::opt_d,
@ -398,7 +399,7 @@ sub get_options_from_array {
sub parse_options { sub parse_options {
# Returns: N/A # Returns: N/A
# Defaults: # Defaults:
$Global::version = 20110422; $Global::version = 20110503;
$Global::progname = 'parallel'; $Global::progname = 'parallel';
$Global::infinity = 2**31; $Global::infinity = 2**31;
$Global::debug = 0; $Global::debug = 0;
@ -733,6 +734,9 @@ sub open_or_exit {
# file handle to read-opened file # file handle to read-opened file
# exits if file cannot be opened otherwise # exits if file cannot be opened otherwise
my $file = shift; my $file = shift;
if($file eq "-") {
return ($Global::original_stdin || *STDIN);
}
my $fh = gensym; my $fh = gensym;
if(not open($fh,"<",$file)) { if(not open($fh,"<",$file)) {
print STDERR "$Global::progname: ". print STDERR "$Global::progname: ".

View file

@ -208,12 +208,18 @@ Read items from the file I<input-file> instead of stdin (standard input). If
you use this option, stdin is given to the first process run. you use this option, stdin is given to the first process run.
Otherwise, stdin is redirected from /dev/null. Otherwise, stdin is redirected from /dev/null.
If multiple B<-a> are given, one line will be read from each of the (Below is unimplemented. Acts like --xapply now)
files. The arguments can be accessed in the command as B<{1}>
.. B<{>I<n>B<}>, so B<{1}> will be a line from the first file, and
B<{6}> will refer to the line with the same line number from the 6th
file.
If multiple B<-a> are given, all combinations of all lines will be
generated. E.g. 1 2 and a b c will result in the combinations (1,a)
(1,b) (1,c) (2,a) (2,b) (2,c). This is useful for replacing nested
for-loops.
The arguments can be accessed in the command as B<{1}>
.. B<{>I<n>B<}>, so B<{1}> will be a line from the first file, and
B<{6}> will refer to a line from the 6th file.
See also B<--xapply>
=item B<--arg-file-sep> I<sep-str> =item B<--arg-file-sep> I<sep-str>
@ -1154,6 +1160,15 @@ See also B<-m>.
Exit if the size (see the B<-s> option) is exceeded. Exit if the size (see the B<-s> option) is exceeded.
=item B<--xapply> (Unimplimented)
Read multiple files like B<xapply>. If multiple B<-a> are given, one
line will be read from each of the files. The arguments can be
accessed in the command as B<{1}> .. B<{>I<n>B<}>, so B<{1}> will be a
line from the first file, and B<{6}> will refer to the line with the
same line number from the 6th file.
=item B<--shebang> =item B<--shebang>
=item B<--hashbang> =item B<--hashbang>