During CP overwriting in RedHat, No matter what parameter-F is added or whether the request is overwritten or not, this is intolerable when writing scripts or a large number of CP overwriting operations...
Try to explain this problem
Create an experiment environment:
[Root @ devdb ~] # Mkdir-P testing/1111
[Root @ devdb ~] # Mkdir-P testing/2222
[Root @ devdb ~] # Touch test/1111/aaa.txt
The directory structure is as follows:
[Root @ devdb ~] # Ls-r test/
Test /:
1111 2222
Testing/1111:
Aaa.txt
[Note] There are two folders 1111,2222 under test. There is a aaa.txt in 1111. now we need to copy the aaa.txt file to 2222.
The first copy is successful because there is no file in the 2222 folder.
[Root @ devdb ~] # Cp-r test/1111/aaa.txt test/2222/
Run this command again, and the prompt is:
[Root @ devdb ~] # Cp-r test/1111/aaa.txt test/2222/
CP: overwrite 'test/2222/aaa.txt '?
This is because there is an aaa.txt under 2222. let's take a look:
[Root @ devdb ~] # Ls-r test/
Test /:
1111 2222
Testing/1111:
Aaa.txt
Testing/2222:
Aaa.txt
If a large number of files already exist and must be overwritten, what should I do without prompting me?
[Root @ devdb ~] # Cp-r-F test/1111/aaa.txt test/2222/
CP: overwrite 'test/2222/aaa.txt '?
Adding-F does not work either...
This is because RedHat creates an alias for CP:
[Root @ devdb ~] # Alias
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 Vi = 'vim'
Alias which = 'Alias |/usr/bin/which -- tty-only -- read-alias -- show-dot -- show-tilde'
When you execute CP, the actual execution is CP-I
Yes
[Root @ devdb ~] # Vi ~ /. Bashrc
Add "#" before alias CP = 'cp-I 'to comment out this line: WQ! Save launch
#. Bashrc
# User specific aliases and functions
Alias Rm = 'rm-I'
# Alias CP = 'cp-I'
Alias mv = 'mv-I'
# Source Global definitions
If [-F/etc/bashrc]; then
./Etc/bashrc
Fi
Valid after Logon