Tuesday, 12 January 2016

Linux Directory Copy

07:53 Posted by Jurgens Krause , , , , No comments
Easy to use, easy to forget

Copy directory and subdirectories
The -R flag is to signal a recursive copy

cp -R source-dir dst-dir

Note that this will place source-dir/* in dst-dir. If you want to place source-dir/* in dst-dir/source-dir/* you must use the following command:

mkdir /dst-dir/source-dir
cp -R source-dir dst-dir/source-dir

If you want to move all directories to sub-directory, in case you used the wrong command above, use the following:

mv !(subdir) subdir


0 comments:

Post a comment