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
Post a Comment