How to pipe output from grep to cp?

grep -l -r “TWL” –exclude=*.csv* | xargs cp -t ~/data/lidar/tmp-ajp2/ Explanation: grep -l option to output file names only xargs to convert file list from the standard input to command line arguments cp -t option to specify target directory (and avoid using placeholders)

git copy file, as opposed to `git mv`

The short answer is just “no”. But there is more to know; it just requires some background. (And as JDB suggests in a comment, I’ll mention why git mv exists as a convenience.) Slightly longer: you’re right that Git will diff files, but you may be wrong about when Git does these file-diffs. Git’s internal …

Read more

linux wildcard usage in cp and mv

Let’s talk about how wildcards work for a minute. cp *.txt foo doesn’t actually invoke cp with an argument *.txt, if any files matching that glob exist. Instead, it runs something like this: cp a.txt b.txt c.txt foo Similarly, something like mv *.txt *.old …can’t possibly know what to do, because when it’s invoked, what …

Read more