Linux cancels the cp command to overwrite the file prompt method

  
                

Use the cp command to copy files on Linux systems, but when you use the cp command to copy files to the dir directory, you will always be prompted to overwrite the files. So how do you cancel the prompt to let Linux copy files directly?

In fact, this tip is a nice feature, it is possible to prevent damage to the system caused by our negligence, but if you do not want to see the message of these interactions it? For example, we need to write a script to install some files into the specified directory, then we certainly do not want to see the prompt.

You can try the -f option, and -f generally means enforcement.

cp -f file dir

But it seems that the result is not as we hoped, the system will still have an overlay prompt. why?

The reason is very simple, the system will cp command alias to cp -i.

When we execute the cp command, the system often executes cp -i, the -i option indicates that there is interactive prompt information,

So when cp -f is executed, the system actually executes It's cp -i -f, so there will still be an overlay hint.

You can execute the alias command to view the following:

alias cp=‘cp -i’

alias l.=‘ls -d .* --color=auto&rsquo ;

alias ll=‘ls -l --color=auto’

alias ls=‘ls --color=auto’

alias mv=‘ Mv -i’

alias rm=‘rm -i’

alias which=‘alias

Copyright © Windows knowledge All Rights Reserved