I’m used to CP / RM / MV and other commands in FreeBSD. When I encounter a file with the same name, I can directly overwrite it, In Linux (not all of them, but some of them I use). When using the CP / RM / MV command to overwrite a file, you are always prompted to enter yes or no, which is very troublesome. Even if one or two files are copied, it is nothing, but sometimes it is troublesome. You need to enter yes one by one. Even if the – f parameter is added, the forced overwrite cannot be achieved. So check the information Find some tips after reading. The following will only take the CP command as an example to explain in detail
1、 Use the unalias CP command to remove the alias of CP (only this terminal connection session is temporarily cancelled). First, enter the alias command to view the alias set in the system
The code is as follows:
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 to cancel the alias of the CP command
The code is as follows:
[[email protected] ~]# cp filename new/filename
[[email protected] ~]#
After using the unalias CP command, you can use CP filename new / filename without prompting for yes or no. is it convenient
2、 Directly enter the \ CP command to cancel the alias of CP
The code is as follows:
Is it easier than the previous method
3、 By using the pipe method, enter yes automatically
The code is as follows:
cp: overwrite `new/filename’? [[email protected] ~]#
I entered yes for us