Editing
Linux commands
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Copy old directory to new directory ==== * {{kbd | key=cp -a ''old_dir new_dir/''}} or {{kbd | key=cp -a ''old_dir/ new_dir/''}} ({{Linux}})<ref> <pre>from manual: -a, --archive same as -dR --preserve=all -d same as --no-dereference --preserve=links --preserve[=ATTR_LIST] preserve the specified attributes (default: mode,ownership,timestamps), if possible addi- tional attributes: context, links, xattr, all -R, -r, --recursive copy directories recursively</pre></ref><ref>[https://superuser.com/questions/61611/how-to-copy-with-cp-to-include-hidden-files-and-hidden-directories-and-their-con unix - How to copy with cp to include hidden files and hidden directories and their contents? - Super User]</ref> ** If the folder {{kbd | key=new_dir}} exists already, system will create the folder {{kbd | key=old_dir}} and all files and sub folders under {{kbd | key=old_dir}} will copy to the path {{kbd | key=new_dir}}/{{kbd | key=old_dir}}. ** If the folder {{kbd | key=new_dir}} NOT exists, all files and sub folders under {{kbd | key=old_dir}} will copy to the folder {{kbd | key=new_dir}}. * {{kbd | key=cp -a ''old_dir/* new_dir/''}} ({{Linux}}): All files and sub folders under {{kbd | key=old_dir}} will copy to the folder {{kbd | key=new_dir}}. * {{kbd | key=copy /Y ''old_dir new_dir/''}} ({{Win}})<ref> /Y 不顯示覆寫現存目的檔案的確認提示。 (引用自 copy /? 命令說明)</ref> * make new directory & copy all old files to new directory ** mkdir ''new_dir'' ** cp ''old_dir/* new_dir'' * [https://askubuntu.com/questions/91740/how-to-move-all-files-in-current-folder-to-subfolder How to move all files in current folder to subfolder? - Ask Ubuntu]
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information