bash - Way to change xargs arguments to include a flag per argument? -
i have passing experience xargs, don't quite know how this:
- i have list of archives retrieved tarsnap using
tarsnap --list-archives
- i want delete archives day (there 24 made each day)
i can use xargs accomplish this:
tarsnap --list-archives | grep 2014-06-09 | xargs -n 1 tarsnap -df
however runs tarsnap on , on again 1 argument @ time (which expected):
tarsnap -df 2014-06-09-00 tarsnap -df 2014-06-09-01 tarsnap -df 2014-06-09-02 ... etc ...
the tarsnap documentation states can delete multiple archives passing in multiple -f
flags:
tarsnap -d -f 2014-06-09-00 -f 2014-06-09-01 -f 2014-06-09-02 # ... , on
is there way accomplish xargs?
(aside: might pointless this, since have feeling running tarsnap multiple -f
flags causes tarsnap run multiple times, 1 argument @ time... wrong)
using idea quite similar @choroba's, can rid of grep
altogether , use sed
instead:
tarsnap --list-archives | sed -n '/2014-06-09/s/^/-f /p' | xargs tarsnap -d
Comments
Post a Comment