How to pipe output from grep to cp?
you need xargs with the placeholder option:
grep -r "TWL" --exclude=*.csv* | xargs -I '{}' cp '{}' ~/data/lidar/tmp-ajp2/
normally if you use xargs
, it will put the output after the command, with the placeholder ('{}'
in this case), you can choose the location where it is inserted, even multiple times.