Yea the reason for cp
command to be interactive because in many common shells by default copy comes with alias as cp -i
this can be found by running command as follows :
alias cp
output will be
alias cp='cp -i'
There are different ways to solve it. Solutions are :
Solution 1. Set alias for that session/permanently in the system or offload alias for cp command.
unset alias: will remove alias for that command.
unalias cp
or
resetting alias:
alias cp='cp'
the above command will set alias for cp
to be just cp
itself instead of cp -i
. So you can run copy commands as many as you want without interactive mode just for that terminal session only(temporary). To make that permanent you may reset alias in respective files say
Bash – ~/.bashrc
ZSH – ~/.zshrc
Fish – ~/.config/fish/config.fish
Solution 2. Run with cp
command with a backslash \
at the beginning of the copy command.
\cp foo.log /tmp/
This will effectively ignores the alias for the cp
command just for that command only.
Inference:
Solution 1 is good to set it temporary or permanent if you intend to run lot of cp
commands and you want to turn off the interactive mode.
Solution2 is good if you only have couple of cp
commands only and don't want to reset the alias, this will be good.