I have the following directory structure.
dirA/[fileA, someB, barC, fileD, someE, barF] dirB/[fileA, barC, someE]
I want to copy only files from dirA to dirB which are already present in dirB. How do I do this selective copy?
I have the following directory structure.
dirA/[fileA, someB, barC, fileD, someE, barF] dirB/[fileA, barC, someE]
I want to copy only files from dirA to dirB which are already present in dirB. How do I do this selective copy?
You could for instance use the find command with the -exec option. You'd probably use some syntax like the following (has to be run in dirB, and be aware that it's recursive):
The -type f tells find to only take into account regular files, the -exec says: run the following command on every file. The \; at the end terminates the command to be run. The {} is a placeholder that is replaced by the actual filename by find. Check out the man page of find for details and other usage examples.
Here's what happens on my PC: