Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
LemonWiki共筆
Search
Search
Appearance
Log in
Personal tools
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Linux commands
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
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 & overwrite file === Copy and overwrite file without prompt (confirmation) * On {{Linux}} {{kbd | key=cp -f ''to_be_copy.file'' ''to_be_overwrote.file''}} <ref>[http://www.ewdna.com/2012/05/linux-cp-force-overwrite.html Linux:檔案複製強制覆寫, cp force overwrite @ 符碼記憶]</ref> * On {{Linux}} {{kbd | key=/bin/cp -f ''to_be_copy.file'' ''to_be_overwrote.file''}} * On {{Win}} {{kbd | key=<nowiki>copy /Y C:\source\some.file C:\target\</nowiki>}}<ref>[https://home.csulb.edu/~murdock/copy.html DOS Command: COPY]</ref> ==== 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] ==== Rename (move) files or directory ==== * {{kbd | key=mv ''/path/to/old_folder_name /path/to/new_folder_name''}} ({{Linux}})<ref>[http://www.liamdelahunty.com/tips/linux_rename_directory.php Linux Rename Files, Folders or Directories]</ref> * {{kbd | key=mv ''/path/to/old.file /path/to/new.file''}} ({{Linux}}) * {{kbd | key=mv ''/path/to/file /path/to/new_folder_name''}} ({{Linux}}) * {{kbd | key=rename ''old_folder_name new_folder_name''}} ({{Win}})<ref>[http://www.computerhope.com/renamehl.htm MS-DOS ren and rename command help]</ref>
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)