mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-12-22 12:47:54 +00:00
parallel: --plus {//regexp/str} replace every regexp with str.
This commit is contained in:
parent
d2753adec5
commit
2f85da8167
|
@ -2731,7 +2731,9 @@ sub init_globals() {
|
|||
# Bash ${a%%def}
|
||||
'{%%([^}]+?)}' => 's/$$1$//;',
|
||||
# Bash ${a/def/ghi} ${a/def/}
|
||||
'{/([^}]+?)/([^}]*?)}' => 's/$$1/$$2/;',
|
||||
'{/([^}/]+?)/([^}]*?)}' => 's/$$1/$$2/;',
|
||||
# Bash ${a//def/ghi} ${a//def/}
|
||||
'{//([^}]+?)/([^}]*?)}' => 's/$$1/$$2/g;',
|
||||
# Bash ${a^a}
|
||||
'{^([^}]+?)}' => 's/^($$1)/uc($1)/e;',
|
||||
# Bash ${a^^a}
|
||||
|
|
|
@ -1937,27 +1937,28 @@ B<{uniq}> skips jobs where values from two input sources are the same.
|
|||
|
||||
Shorthands for variables:
|
||||
|
||||
{slot} $PARALLEL_JOBSLOT (see {%})
|
||||
{sshlogin} $PARALLEL_SSHLOGIN
|
||||
{host} $PARALLEL_SSHHOST
|
||||
{agrp} $PARALLEL_ARGHOSTGROUPS
|
||||
{hgrp} $PARALLEL_HOSTGROUPS
|
||||
{slot} $PARALLEL_JOBSLOT (see {%})
|
||||
{sshlogin} $PARALLEL_SSHLOGIN
|
||||
{host} $PARALLEL_SSHHOST
|
||||
{agrp} $PARALLEL_ARGHOSTGROUPS
|
||||
{hgrp} $PARALLEL_HOSTGROUPS
|
||||
|
||||
The following dynamic replacement strings are also activated. They are
|
||||
inspired by bash's parameter expansion:
|
||||
|
||||
{:-str} str if the value is empty
|
||||
{:num} remove the first num characters
|
||||
{:pos:len} substring from position pos length len
|
||||
{#regexp} remove prefix regexp (non-greedy)
|
||||
{##regexp} remove prefix regexp (greedy)
|
||||
{%regexp} remove postfix regexp (non-greedy)
|
||||
{%%regexp} remove postfix regexp (greedy)
|
||||
{/regexp/str} replace regexp with str
|
||||
{^str} uppercase str if found at the start
|
||||
{^^str} uppercase str
|
||||
{,str} lowercase str if found at the start
|
||||
{,,str} lowercase str
|
||||
{:-str} str if the value is empty
|
||||
{:num} remove the first num characters
|
||||
{:pos:len} substring from position pos length len
|
||||
{#regexp} remove prefix regexp (non-greedy)
|
||||
{##regexp} remove prefix regexp (greedy)
|
||||
{%regexp} remove postfix regexp (non-greedy)
|
||||
{%%regexp} remove postfix regexp (greedy)
|
||||
{/regexp/str} replace one regexp with str
|
||||
{//regexp/str} replace every regexp with str
|
||||
{^str} uppercase str if found at the start
|
||||
{^^str} uppercase str
|
||||
{,str} lowercase str if found at the start
|
||||
{,,str} lowercase str
|
||||
|
||||
See also: B<--rpl> B<{}>
|
||||
|
||||
|
|
|
@ -442,7 +442,7 @@ par_plus_dyn_repl() {
|
|||
parallel --plus echo {2:-myval} ::: "wrong" ::: "$myvar" ::: "wrong"
|
||||
parallel --plus echo {-2:-myval} ::: "wrong" ::: "$myvar" ::: "wrong"
|
||||
|
||||
myvar=abcAaAdef
|
||||
myvar=abcAaBdefCdefDdef
|
||||
echo ${myvar:2}
|
||||
parallel --rpl '{:(\d+)} substr($_,0,$$1) = ""' echo {:2} ::: "$myvar"
|
||||
parallel --plus echo {:2} ::: "$myvar"
|
||||
|
@ -488,6 +488,12 @@ par_plus_dyn_repl() {
|
|||
parallel --plus echo {2/def/ghi} ::: "wrong" ::: "$myvar" ::: "wrong"
|
||||
parallel --plus echo {-2/def/ghi} ::: "wrong" ::: "$myvar" ::: "wrong"
|
||||
|
||||
echo ${myvar//def/ghi}
|
||||
parallel --rpl '{//(.+?)/(.+?)} s/$$1/$$2/g;' echo {//def/ghi} ::: "$myvar"
|
||||
parallel --plus echo {//def/ghi} ::: "$myvar"
|
||||
parallel --plus echo {2//def/ghi} ::: "wrong" ::: "$myvar" ::: "wrong"
|
||||
parallel --plus echo {-2//def/ghi} ::: "wrong" ::: "$myvar" ::: "wrong"
|
||||
|
||||
echo ${myvar^a}
|
||||
parallel --rpl '{^(.+?)} s/^($$1)/uc($1)/e;' echo {^a} ::: "$myvar"
|
||||
parallel --plus echo {^a} ::: "$myvar"
|
||||
|
|
|
@ -1605,54 +1605,59 @@ par_plus_dyn_repl myval
|
|||
par_plus_dyn_repl myval
|
||||
par_plus_dyn_repl myval
|
||||
par_plus_dyn_repl myval
|
||||
par_plus_dyn_repl cAaAdef
|
||||
par_plus_dyn_repl cAaAdef
|
||||
par_plus_dyn_repl cAaAdef
|
||||
par_plus_dyn_repl cAaAdef
|
||||
par_plus_dyn_repl cAaAdef
|
||||
par_plus_dyn_repl cAaBdefCdefDdef
|
||||
par_plus_dyn_repl cAaBdefCdefDdef
|
||||
par_plus_dyn_repl cAaBdefCdefDdef
|
||||
par_plus_dyn_repl cAaBdefCdefDdef
|
||||
par_plus_dyn_repl cAaBdefCdefDdef
|
||||
par_plus_dyn_repl cAa
|
||||
par_plus_dyn_repl cAa
|
||||
par_plus_dyn_repl cAa
|
||||
par_plus_dyn_repl cAa
|
||||
par_plus_dyn_repl cAa
|
||||
par_plus_dyn_repl 9
|
||||
par_plus_dyn_repl 9
|
||||
par_plus_dyn_repl 17
|
||||
par_plus_dyn_repl 17
|
||||
par_plus_dyn_repl 1
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl AaAdef
|
||||
par_plus_dyn_repl AaAdef
|
||||
par_plus_dyn_repl AaAdef
|
||||
par_plus_dyn_repl AaAdef
|
||||
par_plus_dyn_repl AaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaA
|
||||
par_plus_dyn_repl abcAaA
|
||||
par_plus_dyn_repl abcAaA
|
||||
par_plus_dyn_repl abcAaA
|
||||
par_plus_dyn_repl abcAaA
|
||||
par_plus_dyn_repl abcAaAghi
|
||||
par_plus_dyn_repl abcAaAghi
|
||||
par_plus_dyn_repl abcAaAghi
|
||||
par_plus_dyn_repl abcAaAghi
|
||||
par_plus_dyn_repl abcAaAghi
|
||||
par_plus_dyn_repl AbcAaAdef
|
||||
par_plus_dyn_repl AbcAaAdef
|
||||
par_plus_dyn_repl AbcAaAdef
|
||||
par_plus_dyn_repl AbcAaAdef
|
||||
par_plus_dyn_repl AbcAaAdef
|
||||
par_plus_dyn_repl AbcAAAdef
|
||||
par_plus_dyn_repl AbcAAAdef
|
||||
par_plus_dyn_repl AbcAAAdef
|
||||
par_plus_dyn_repl AbcAAAdef
|
||||
par_plus_dyn_repl AbcAAAdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl AaBdefCdefDdef
|
||||
par_plus_dyn_repl AaBdefCdefDdef
|
||||
par_plus_dyn_repl AaBdefCdefDdef
|
||||
par_plus_dyn_repl AaBdefCdefDdef
|
||||
par_plus_dyn_repl AaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefDdef
|
||||
par_plus_dyn_repl abcAaBdefCdefD
|
||||
par_plus_dyn_repl abcAaBdefCdefD
|
||||
par_plus_dyn_repl abcAaBdefCdefD
|
||||
par_plus_dyn_repl abcAaBdefCdefD
|
||||
par_plus_dyn_repl abcAaBdefCdefD
|
||||
par_plus_dyn_repl abcAaBghiCdefDdef
|
||||
par_plus_dyn_repl abcAaBghiCdefDdef
|
||||
par_plus_dyn_repl abcAaBghiCdefDdef
|
||||
par_plus_dyn_repl abcAaBghiCdefDdef
|
||||
par_plus_dyn_repl abcAaBghiCdefDdef
|
||||
par_plus_dyn_repl abcAaBghiCghiDghi
|
||||
par_plus_dyn_repl abcAaBghiCghiDghi
|
||||
par_plus_dyn_repl abcAaBghiCghiDghi
|
||||
par_plus_dyn_repl abcAaBghiCghiDghi
|
||||
par_plus_dyn_repl abcAaBghiCghiDghi
|
||||
par_plus_dyn_repl AbcAaBdefCdefDdef
|
||||
par_plus_dyn_repl AbcAaBdefCdefDdef
|
||||
par_plus_dyn_repl AbcAaBdefCdefDdef
|
||||
par_plus_dyn_repl AbcAaBdefCdefDdef
|
||||
par_plus_dyn_repl AbcAaBdefCdefDdef
|
||||
par_plus_dyn_repl AbcAABdefCdefDdef
|
||||
par_plus_dyn_repl AbcAABdefCdefDdef
|
||||
par_plus_dyn_repl AbcAABdefCdefDdef
|
||||
par_plus_dyn_repl AbcAABdefCdefDdef
|
||||
par_plus_dyn_repl AbcAABdefCdefDdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
par_plus_dyn_repl abcAaAdef
|
||||
|
|
Loading…
Reference in a new issue