command line - how do you copy a directory and its contents to a new location under a new directory name? - Ask Ubuntu


i'm new linux command line , trying grips copy command @ moment.

can please tell me if it's possible copy directory subdirectories , associated files new directory new name e.g. directory_backup?

thanks , in advance

you use -r (copy recursively) , specify new name

cp -r /path/to/directory /path/to/location/new-name 

replace real paths... example copy stuff home directory existing directory backup , name new directory stuff-backup (if directory exists, note stuff copied into it, not overwrite it).

cp -r ~/stuff ~/backup/stuff-backup 

~ shortcut home directory /home/$user or /home/zanna in case. can omit if current working directory home directory - can see prompt

zanna@monster:~$               ^--the ~ here - home! 

you can add -v verbose flag make cp report each copy being performed...

$ cp -vr stuff backup/stuff-backup 'stuff/thing1' -> 'backup/stuff-backup/thing1' 'stuff/thing2' -> 'backup/stuff-backup/thing2 ... 

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User