Linux CP command Bulk copy no prompt method

Source: Internet
Author: User

Features: Copying Files or directories
Note: The CP instruction is used to copy files or directories, such as specifying more than two files or directories at the same time, and the final destination is an existing directory, it will copy all the previously specified files or directories into this directory. If you specify multiple files or directories at the same time, and the final destination is not an existing directory, an error message appears
Parameters:
-A or--archive the effect of this parameter with the same as specifying the "-DPR" parameter
- B or--backup Delete, overwrite destination files are backed up first, backed up files or directories are also created as symbolic links and point to source files or directories linked to source files or directories. If this parameter is not added, the source file or directory will be copied directly if a symbolic link is encountered during the copy process .
-F or--force forcibly copy a file or directory, regardless of whether the destination file or directory already exists
-I or--interactive overwrite the file before asking the user
-L or--link to create a hard link to the source file instead of copying the file
-P or--preserve preserves the properties of the source file or directory, including the owner, the owning group, the permissions and the time
- p or--parents retains the path to the source file or directory, which can be an absolute or relative path, and the destination directory must already be in
- R recursive processing, the files under the specified directory and subdirectories are processed together. If the form of the source file or directory is not a directory or symbolic link, it will be treated as normal file
- R or--recursive recursive processing, the files and subdirectories under the specified directory are processed together
-S or--symbolic-link to create symbolic links to source files instead of copying files
-S < back-end string > or--suffix=< back-up string > After backing up the destination file with the "-B" parameter, a backup string is added to the end of the backup file. The default backup character string is the symbol "~"
If you or--update use this parameter, the file will only be copied when the source file has been modified (modification time) when the destination file is updated, or the destination file for the name is not present .
- V or--verbose shows the execution process
- v < backup method > or--version-control=< backup method > Specifies that when backing up files, the backup file name is named in the following 3 ways:
1.numbered or T, the backup number will be used, and the ~1~ string will be added at the end of the word, with the number incremented sequentially
2.simple or never will use a simple backup, the default back-end string is ~, can also be specified by-s
3.existing or nil will use the current mode, the program will first check if there is a backup number, if there is a backup number, if not the use of simple backup
The file system that the file or directory is copied by-X or--one-file-system must be the same as the file system where the CP instruction is executed, otherwise it will not be copied or processed in other partitions
--help Show online Help
--sparse=< Timing > Setting time to save sparse files

--version Display version


copy all files in file A to file B, using the command Cp-ri a/* / If A and B files have duplicate files, there will always be a choice to overwrite or not overwrite the hint,

If there are 100 files of the same name, we have to enter 100 times, it is not very tiring, how to batch processing?

1) All overrides are not prompted:

Cp-if do not inquire, direct coverage;

2) do not overwrite, do not prompt:

This someone said with Reply=no, I have tried, no success do not know. The following method has been tested correctly. Use the awk tool and use the pipeline to input the output N of print "n" into the read that asks whether to overwrite:

awk ' BEGIN {cmd= ' cp-ri a/* b/"; print" n "| cmd;} '

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux CP command Bulk copy no prompt method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.