I have some passing experience with xargs, but I don't quite know how to do this:
tarsnap --list-archives
I can use xargs to accomplish this:
tarsnap --list-archives | grep 2014-06-09 | xargs -n 1 tarsnap -df
However this runs tarsnap over and over again with one argument at a time (which is expected):
tarsnap -df 2014-06-09-00
tarsnap -df 2014-06-09-01
tarsnap -df 2014-06-09-02
... etc ...
The tarsnap documentation states that you can delete multiple archives by passing in multiple -f
flags:
tarsnap -d -f 2014-06-09-00 -f 2014-06-09-01 -f 2014-06-09-02 # ... and so on
Is there a way to accomplish this with xargs?
(Aside: It might be pointless to even do this, since I have a feeling running tarsnap with multiple -f
flags just causes tarsnap to run itself multiple times, one argument at a time... but I could be wrong)
You can actually do this with xargs
$ archivelist=$(tarsnap --list-a|xargs -I {} echo "-f {} ")
$ echo $archivelist
-f 2014-06-09-00 -f 2014-06-09-01 -f 2014-06-09-02 -f 2014-06-09-03
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With