parallel
[Top][All Lists]
Advanced

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

Re: Replacement string to keep only extension?


From: Ole Tange
Subject: Re: Replacement string to keep only extension?
Date: Sun, 9 Oct 2016 16:18:56 +0200

On Wed, Oct 5, 2016 at 4:21 PM, Geoffrey Cleaves <gcleaves@gmail.com> wrote:
> Hi all. Is there a replacement string similar to {//} which keeps only the
> extension? I know it's possible to define a custom replacement pattern but
> I'm running into difficulties since I have so many nested shells and my
> matching parenthesis aren't being recognised.

>From man parallel:

       --plus   Activate additional replacement strings: {+/}
               {+.} {+..} {+...} {..} {...} {/..} {/...}
               {##}. The idea being that '{+foo}' matches
               the opposite of '{foo}' and {} = {+/}/{/} =
               {.}.{+.} = {+/}/{/.}.{+.} = {..}.{+..} =
               {+/}/{/..}.{+..} = {...}.{+...} =
               {+/}/{/...}.{+...}

               {##} is the number of jobs to be run. It is
               incompatible with -X/-m/--xargs.

So:

    parallel --plus echo {+.} ::: name.extension

should print extension.

If you have a problem with quoting, consider putting a --rpl statement
in your ~/.parallel/config. E.g:

--rpl '{0#} $f = "%0".int(1+log(total_jobs())/log(10))."d";
$_=sprintf($f,$job->seq())'

to have {0#} be a 0-padded job-number.


/Ole



reply via email to

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