parallel
[Top][All Lists]
Advanced

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

Re: --nest for nested argument files


From: Hans Schou
Subject: Re: --nest for nested argument files
Date: Tue, 3 May 2011 16:25:05 +0200

2011/5/3 Ole Tange <tange@gnu.org>:
> Following a recent discussion on the list I have given some thought to
> making an option --nest.
>
> --nest

My first thought was --multiply (as in multiply list 1 with list 2)
but I agree that --nest (as in nested for loops) is better.

> Nest argument files. This changes the behaviour of :::: and -a. If
> multiple files are given GNU Parallel will generate all combinations
> of lines from each of the files and replace {1} .. {N} with a line
> from each of the files. If file1 contains the lines "a b c" and file2
> contains the lines "1 2", then "parallel echo {1} {2} :::: file1
> file2" will print: a 1, b 1, c 1, a 2, b 2, c 2.

Example: With a list of files run several several commands on each file.

Compress a list of files and listen quickly to all of them and pick
the one with acceptable sound.

Content of wavfiles:
   foo.wav
   bar.wav

Content of quality:
   1
   5
   10

parallel oggenc -q {1} {2} {2.}_{1}.ogg :::: quality wavfiles
  or
parallel -a quality -a wavfiles oggenc -q {1} {2} {2.}_{1}.ogg

Gives 6 files which looks like:
   foo_1.ogg
   bar_5.ogg

Or as a (hard to read) one-liner:
parallel oggenc -q {1} {2} {2.}_{1}.ogg :::: <(seq 10) <(ls *.wav)

> I see that this might be generally useful for replacing nested
> for-loops, and I know I have had the need for this a few times. So far
> I have not given much thought to how to implement it, but first I
> would like your comments on this.
>
> Do you have a better idea for the syntax? Should it be default (and
> thus the current behaviour would require you to use --xapply)?

I thought --nest was default. I suggest that --keeporder is changed to
be the one to use if you want to run line by line.

> If --nest is combined with -X what would you expect that to do?

I think --arg-file (-a) should conflict or -X should do nothing if
combined with --arg-file.
(If I understand -X correctly)

/hans



reply via email to

[Prev in Thread] Current Thread [Next in Thread]