[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question 2 (argfile input syntax)
From: |
Ole Tange |
Subject: |
Re: Question 2 (argfile input syntax) |
Date: |
Fri, 19 May 2017 00:19:40 +0200 |
On Wed, May 17, 2017 at 10:42 PM, paralleluser
<paralleluser@fastmail.net> wrote:
> Question 2:
> There are a multitude of ways to give GNU parallel arguments contained in a
> file.
>
> 1. cat argfile | parallel
> 2. parallel < argfile
> 3. parallel :::: argfile
> 4. parallel ::: `cat argfile`
> 5. parallel -a argfile
>
> Am I missing any from this list?
The linked versions: :::+ and ::::+, and maybe the using of stdin as -
cat argfile | parallel echo ::: 1 2 3 :::: -
> I am curious as to which you use when and why. I think the answer is beyond
> "personal preference". For example, I would ...
>
> Use #1 if you plan to do additional pipe work before parallel, for example:
> cat argfile | grep xyz | parallel
Yup.
> Use #5 if you are going to use "-a" multiple times so you can refer to {1}
> and {2} etc
> parallel -a argfile1 -a argfile2 command {1} {2}
Or use #3:
parallel command {1} {2} :::: argfile1 argfile2
I find that easier to read - especially when mixed with :::
parallel command {1} {2} {4} {3} :::: argfile1 argfile2 ::: 1 2 3
:::: more files
> I don't see a good reason to use #4
If you use #4 you need to know what you are doing:
echo 1 2 > argfile
parallel echo ::: `cat argfile`
So in the exceptional case where you actually want the line split on
space, it is a solution.
But in most cases #3 is the better (and shorter) choice.
> I think #2 and #3 seem about the same. What advantage is there to use either
> of them over #1?
#2 has the advantage of not running a cat (but if you are concerned by
that, please read:
http://oletange.blogspot.dk/2013/10/useless-use-of-cat.html )
#3 has the advantage that GNU Parallel sees this as an actual file. So
you can use --pipepart:
parallel --block -1 --pipepart wc :::: bigfile
/Ole