Commands such as cp/rm/mv in CentOS force override

Source: Internet
Author: User

Commands such as cp/rm/mv in CentOS force override

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.

  1. [Root @ localhost ~] # Alias
  2. Aliascp = 'cp-I'
  3. Aliasl. = 'LS-d. * -- color = tty'
  4. Aliasll = 'LS-l -- color = tty'
  5. Aliasls = 'ls -- color = tty'
  6. Aliasmv = 'mv-I'
  7. Aliasrm = 'rm-I'
  8. Aliaswhich = 'Alias |/usr/bin/which -- tty-only -- read-alias -- show-dot -- show-tilde'

Enter the unalias cp command to cancel the alias of the cp command

  1. [Root @ localhost ~] # Unaliascp
  2. [Root @ localhost ~] # Cpfilenamenew/filename
  3. [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 convenient?

2. directly enter the \ cp command to cancel the cp alias.

  1. [Root @ localhost ~] # \ Cpfilenamenew/filename
  2. [Root @ localhost ~] #

Is it easier than the previous method?
3. Use MPs queue to automatically enter yes

  1. [Root @ localhost ~] # Yes | cpfilenamenew/filename
  2. 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.