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.
- [Root @ localhost ~] # Alias
- Aliascp = 'cp-I'
- Aliasl. = 'LS-d. * -- color = tty'
- Aliasll = 'LS-l -- color = tty'
- Aliasls = 'ls -- color = tty'
- Aliasmv = 'mv-I'
- Aliasrm = 'rm-I'
- 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
- [Root @ localhost ~] # Unaliascp
- [Root @ localhost ~] # Cpfilenamenew/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 convenient?
2. directly enter the \ cp command to cancel the cp alias.
- [Root @ localhost ~] # \ Cpfilenamenew/filename
- [Root @ localhost ~] #
Is it easier than the previous method?
3. Use MPs queue to automatically enter yes
- [Root @ localhost ~] # Yes | cpfilenamenew/filename
- Cp: overwrite 'new/filename '? [Root @ localhost ~] #
Input yes for us