Cp, rm, mv, and other commands are forcibly overwritten.

Source: Internet
Author: User

I am used to the cp, rm, mv, and other commands in freebsd to directly overwrite files of the same name, but in linux (not necessarily all, maybe I use several ), when you use the cp/rm/mv command to overwrite a file, the system always prompts "yes" or "no". It is very troublesome. If you have one or two files, you can forget it. However, when copying a large number of files, this is troublesome. You need to enter yes one by one. Even if the-f parameter is added, it cannot achieve forced overwrite. After reading the information, find some tips. The following uses the cp command as an example to describe in detail.

1. Use the unaliascp command to remove the cp alias (only this terminal connection session is temporarily canceled). First, enter the alias command to view the alias already set in the system.

[Root @ localhost ~] # Alias cp = 'cp-I 'alias l. = 'LS-d. * -- color = tty 'Alias ll = 'LS-l -- color = tty 'Alias ls = 'ls -- color = tty 'Alias mv = 'mv-I 'alias rm =' rm-I 'Alias which = 'Alias |/usr/bin/which -- tty-only -- read-alias -- show-dot -- show-tilde' enter the unalias cp command, cancel the alias of the cp Command [root @ localhost ~] # Unalias cp [root @ localhost ~] # Cp filename new/filename [root @ localhost ~] # After using the unalias cp command, you can use cp filename new/filename without prompting you to enter yes or no. Is it very convenient? 2. directly enter the \ cp command, it also cancels the cp alias [root @ localhost ~] # \ Cp filename new/filename [root @ localhost ~] # Is it easier than the previous method? 3. If you use pipelines, automatically enter yes [root @ localhost ~] # Yes | cp filename new/filename cp: overwrite 'new/filename '? [Root @ localhost ~] #

Input yes for us

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.