[root@test ~]# cp file1 file2
cp: overwrite `file2'? y
Let's see which cp it's using now.
[root@test ~]# which cp
alias cp='cp -i'
/bin/cp
Oh, now we know cp is not the cp we used to be, it's an alias command. In such situation, you have several options to skip the prompts:
- Redirect "y" to the command in advance. But I don't think it's a good practice.
- Unalias the command. It could be used to meet dynamic requirements, e.g. shell scripts.
- Remove or comment out the alias in the first place ~/.bashrc.
- Choose another alias name for 'cp -i' to distinguish them.
[root@test ~]# echo "y" | cp file1 file2
cp: overwrite `file2'? [root@test ~]#
[root@test ~]# unalias cp
[root@test ~]# which cp
/bin/cp
[root@test ~]# vi ~/.bashrc
...
#alias cp='cp -i'
[root@test ~]# vi ~/.bashrc
...
alias cpi='cp -i'