Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash, can't use xargs replstr after redirect

Tags:

bash

sh

As part of post-commit hook, I try to copy all the files that changed into a local folder - using this script (attached only the relevant part of the script):

svnlook changed ${REPOS} -r ${REV} | sed "s/^....//" | xargs -I {} svnlook cat ${REPOS} {} -r ${REV} > /tmp/commit2/{}

which won't replace the second {} with the xargs argument but use it as is (creating a file name '{}').

Is it possible to replace the argument after the output redirect?

Thanks, Roi

like image 474
Roi Addi Avatar asked May 15 '26 21:05

Roi Addi


1 Answers

Not like that, no. The shell does the redirections, not xargs. xargs isn't even "aware" that a redirection is happening.

You could use something like the following:

svnlook changed ${REPOS} -r ${REV} |
  sed "s/^....//" | 
  while read -r line ; do 
    svnlook cat ${REPOS} "$line" -r ${REV} > /tmp/commit2/"$line"
  done
like image 116
Mat Avatar answered May 17 '26 13:05

Mat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!