[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing multiple flags in a single {} replacement
From: |
Alastair Andrew |
Subject: |
Re: Passing multiple flags in a single {} replacement |
Date: |
Mon, 14 May 2012 19:06:52 +0100 |
Hi Ole,
If I manually run ls -a -l from the command line I get the usual long directory
listing showing all the chmod info, file owner, size, date, name for the files
and directories (including the hidden files). If I run parallel -v -bash -c ls
::: "-l -a" I don't get that. I just get the regular ls output (albeit parallel
reports it as one item per line).
I've tried running parallel -v -bash -c ls ::: "-l -a" on version 20120422
running on Mac OS X 10.6.8 (with bash 4.2.8(1)-release) and using version
20120322 on Ubuntu 10.04 (with bash 4.1.5(1)-release) and neither of them work
as you intended. What version of parallel did you expect your example to work
with?
Thanks,
Alastair.
On 14 May 2012, at 12:49, Ole Tange wrote:
> On Sun, May 13, 2012 at 5:48 PM, Alastair Andrew <a.andrew@strath.ac.uk>
> wrote:
>
>> If you call it with the -d flag it'll run parallel in --dry-run mode
>> echo-ing its proposed runs allowing you to see the addition backslashes in
>> the generated arguments. Using --nice inflates the number backslashes too.
>
> The problem you are experiencing can be summed up as:
>
> parallel -v ls ::: "-l -a"
>
> Your problem is that you want the arguments to be parsed by the shell
> and not escaped. That is in contrast to this situation:
>
> parallel -v ls ::: "my file"
>
> where you do _not_ want the argument to be parsed by the shell, but
> want it escaped so it is interpreted as a single argument.
>
> What you are hitting is therefore a design decision which makes sense
> most of the time, but not all the time.
>
> So what to do? One solution is to give the command line to 'bash -c':
>
> parallel -v bash -c ls ::: "-l -a"
>
> by doing so you can have your cake and eat it, too, so commands like
> this will be possible:
>
> parallel -v touch {1}\; bash -c ls {2} ::: "my file" ::: "-l -a"
>
> Here the first part is quoted and the second part unquoted (by bash
> -c). It also does the right thing with --nice.
>
>
> /Ole