[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Solution looking for (more than one) problem
From: |
Ole Tange |
Subject: |
Solution looking for (more than one) problem |
Date: |
Sat, 11 Mar 2017 00:14:12 +0100 |
I like Bash's removal of strings:
$ file=my.tar.gz
$ echo ${file%.tar.gz}
my
So far the --rpl strings are fixed. There is no way to "pass an
argument". I have changed that:
parallel --rpl '{%(.*?)} s/$$1//' echo {%.tar.gz} ::: my.tar.gz
To ask for an argument you put '(regexp)' in the replacement string,
and you access them using $$1 $$2 ...
The --rpl can of course be put in ~/.parallel/config
This can also take multiple arguments:
parallel --rpl '{@(\d+)\S(\d+)\S(\d+)}
if($$3 > 31) { ($$1,$$2,$$3) = ($$3,$$2,$$1) }
if($$2 > 12) { ($$1,$$2,$$3) = ($$1,$$3,$$2) }
$$1 = ($$1%100 + 1900); $_="$$1-$$2-$$3"
' echo {@99-12-31} {@12.31.99} {@31/12-1999} ::: a
parallel --rpl '{(.*?)/(.*?)} $_="$$2$_$$1"' echo {swap/these} ::: -middle-
But those are pretty stupid examples. Can you find a use where
multiple arguments would make sense?
Also it would be helpful if you could read the --rpl section in the
manual. Can this be described better?
/Ole
- Solution looking for (more than one) problem,
Ole Tange <=