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