#>cp -rf /dir1/* /dir2
cp: overwrite ‘/dir1/subdir1/file.dat with /dir2/subdir1/file.dat’
Since I had about 300 files to copy, it was not easy for me to keep typing ‘y’. So, I did some searches and found the following solution.
1. Run the alias command to check if cp was set to alias with a different command.
#> alias
alias cp='cp -i'
alias mv='mv -i'
alias rm='rm -i'
Which you can see, cp was acturaly alias as 'cp –i'. -i, --interactive, which means prompt before overwrite. Therefore, -f was ignored.
I want to remove the alias so I could copy the files. To do so, I needed to issue the following command:
#>unalias cp
However, in normally situation, we do want to use cp –i to prevent accidentally override files. Therefore, I issued the following command after done with copying the files:
#>alias ‘cp=cp –I’
One more detail, to perform the above steps, it required root access. So, what happen if we don’t have root access? Well, the following command works:
Command:
#> /bin/cp -rf /dir1/* /dir2
It is because that the /bin/cp copy is not alias to any other command switch.
