谁能告诉我为什么当我输入:
mv -f ./tmp/members ./
我得到:
mv: cannot move `./tmp/members' to a subdirectory of itself, `./members'
此外,移动该目录的正确方法是什么?
此外,./members 下已经有一个目录...我想完全覆盖这个目录,而不仅仅是向其中添加新内容。
Directory Structure:
./
./members
./members/srno
./members/srno/expired
./members/1
./members/1/active
./members/members
./members/members/srno
./members/members/srno/expired
./members/members/1
./members/members/1/active
./members/members/57364
./members/members/57364/expired
./members/members/11939
./members/members/11939/expired
./members/members/123
./members/members/123/expired
./members/members/73331
./members/members/73331/expired
./members/members/88144
./members/members/88144/expired
./members/members/25051
./members/members/25051/expired
./members/57364
./members/57364/expired
./members/11939
./members/11939/expired
./members/123
./members/123/expired
./members/73331
./members/73331/expired
./members/88144
./members/88144/expired
./members/remove
./members/25051
./members/25051/expired
./index.html
./tmp
./tmp/members
./tmp/members/srno
./tmp/members/srno/expired
./tmp/members/1
./tmp/members/1/active
./tmp/members/57364
./tmp/members/57364/expired
./tmp/members/11939
./tmp/members/11939/expired
./tmp/members/123
./tmp/members/123/expired
./tmp/members/73331
./tmp/members/73331/expired
./tmp/members/88144
./tmp/members/88144/expired
./tmp/members/25051
./tmp/members/25051/expired
./tmp/subscribers.xml
./premium.cgi
谢谢!
-埃里克
答案1
请尝试以下操作:
cp -rf ./tmp/members/* ./
随后,./tmp/members
如果您不想保留副本,请删除。 mv
不会“覆盖”。
使用相对路径是一个坏习惯,你很快就会后悔。我建议在合理的情况下使用完整路径。
答案2
这应该有效:
mv -f ./tmp/members .
答案3
另一个答案(尽管你已经接受了另一个):
mv ./members ./.trash-members ; mv ./tmp/members ./ ; rm -rf ./.trash-members &
这样,旧目录就会在后台被删除,新目录就会在很短的时间内放到位(只要您在同一个文件系统上,这两个移动就会非常快)
还请注意,该解决方案没有按应有的方式使用安全临时文件。