parallel
[Top][All Lists]
Advanced

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

Re: echo quotes using parallel


From: Ole Tange
Subject: Re: echo quotes using parallel
Date: Sat, 9 Feb 2013 00:05:52 +0100

On Fri, Feb 8, 2013 at 9:06 PM, Uma Nagaswamy <uma.nagaswamy@gmail.com> wrote:
>
> Hi Ole,

Please use parallel@gnu.org for support questions.

> Hope you are doing good. I am trying to generate a sequence using parallel
> with quotes.
> But parallel seems to strip the quotes. Here is what I tried:
>
> seq 1 100|parallel echo -e "\"cycle_{} BIGINT,\""| head -2
> cycle_1 BIGINT,
> cycle_2 BIGINT,
>
>
> What I want is this:
>
> seq 1 100| xargs -I {}  echo -e "\"cycle_{} BIGINT,\""| head -2
> "cycle_1 BIGINT,"
> "cycle_2 BIGINT,"
>
> Do you any suggestions?

>From the man page (Section QUOTING);

       Often you can simply put \' around every ':

         perl -ne '/^\S+\s+\S+$/ and print $ARGV,"\n"' file

       can be quoted:

         parallel perl -ne \''/^\S+\s+\S+$/ and print $ARGV,"\n"'\' ::: file

:

     If the special characters should not be evaluated by the sub
shell then you need to protect it against evaluation from both the
       shell starting GNU parallel and the sub shell:

       echo test | parallel echo {} \\\$VAR

       Prints: test $VAR

       GNU parallel can protect against evaluation by the sub shell by using -q:

       echo test | parallel -q echo {} \$VAR

       Prints: test $VAR

So the man page suggests three solutions:

  $ seq 1 100 | parallel echo -e \'"\"cycle_{} BIGINT,\""\' | head -2

  $ seq 1 100 | parallel echo -e \"\\\"cycle_{} BIGINT,\\\"\" | head -2

  $ seq 1 100 | parallel -q echo -e "\"cycle_{} BIGINT,\"" | head -2

and they all work.

Please help rephrasing the man page so you would have found these solution.


/Ole



reply via email to

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