Linux: Copy files and folders recursively

Say you want to copy a directory (a folder) and all of its contents to a different directory. AND it contains subdirectories
OLD LOCATION : /2013_records/
NEW LOCATION: ../someNewPathHere/archive/2013_records/
If you try to use the cp command, you may see that the subdirectories are not being copies.
cp 2013_records/* ../someNewPathHere/archive/2013_records/
You will probably get an "error" like this, and nothing happens:
cp: omitting directory '2013_records'
You should add a few flags to your cp command:
-a = archive (meaning keep all of the timestamp and ownership info)
-v = verbose (meaning, show me what you're doing.)
-r = recursively (meaning everything below the top level)
So, the correct copy command should have been.
cp -avr 2013_records/* ../someNewPathHere/archive/2013_records/

No comments :

Post a Comment