ファイルを上書きすることなくファイルをコピーまたは移動するにはどうすればよいですか?

ファイルを上書きすることなくファイルをコピーまたは移動するにはどうすればよいですか?

私が試したこと:

root@host [/home1]# cp -f hello /home3
cp: omitting directory `hello'
root@host [/home1]# cp -rf hello /home3
cp: overwrite `/home3/hello/.buildpath'? y
cp: overwrite `/home3/hello/.bash_logout'? y
cp: overwrite `/home3/hello/.project'? ^C

彼らはいつも私に保証したいと尋ねます。 mvを使用しても機能しません。ではどうすればいいですか?

私が試した他のもの:

root@host [/home1]# cp -rf hello /home3
cp: overwrite `/home3/hello/.buildpath'? y
cp: overwrite `/home3/hello/.bash_logout'? y
cp: overwrite `/home3/hello/.project'? ^C
root@host [/home1]# cp -force hello /home3
cp: invalid option -- 'o'
Try `cp --help' for more information.
root@host [/home1]# cp --remove-destination hello /home4
cp: omitting directory `hello'
root@host [/home1]# cp --remove-destination hello /home3
cp: omitting directory `hello'
root@host [/home1]# cp --remove-destination -r hello /home3
cp: overwrite `/home3/hello/.buildpath'? ^C
root@host [/home1]#

ベストアンサー1

要求せずに強制的にオーバーライドするには、次のコマンドを使用する必要があります。MVオプション「-f」を使用するには、manを使用してオプションを確認してください。

男性MV:

   -f, --force
          do not prompt before overwriting

例:

mv -f test.tmp test.txt

おすすめ記事