Sunday 1 October 2017

bash - Copy a directory on Unix


How can I copy a directory structure, dir1, to dir2, (with all the subdirectories) on Unix using the terminal window?



Answer



cp -rf /source/path/ /destination/path/

-r = recursive, copies all the sub-directories


-f = force, if an existing destination file cannot be opened, remove it and try again


Note You should be careful when using the -f flag because it will forcefully overwrite anything you copy to. Thank @Nifle for this suggestion.


You may want to use the * wildcard to copy all of the files in the directory if you need to.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...