Bash:如何将文件夹中的所有内容向上移动一层?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9964082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bash: How can I move all the content in the folder up to one level?
提问by Kit Ho
How can I move the whole folder of _vim into ~/.vim?
如何将 _vim 的整个文件夹移动到 ~/.vim 中?
$ mv ~/.vim/_vim/ ~/.vim
mv: `/home/kithokit/.vim/_vim/' and `/home/kithokit/.vim/_vim' are the same file
I cannot do that.
Basically what I want to do is just move all the contents inside _vimfolder up to one level, which is in ~/.vim/
我不能这样做。基本上我想要做的只是将_vim文件夹中的所有内容移动到一个级别,即~/.vim/
回答by Dunes
mv ~/.vim/_vim/* ~/.vim
Bash expands the *such the command now reads
Bash 扩展了*这样的命令现在读取
mv ~/.vim/_vim/file_1 ... ~/.vim/_vim/file_n ~/.vim
回答by thb
If you want to be careful to move hidden dotfiles as well as regular, visible files, and also not to clobber any files already in ~/.vim/, then do this:
如果您想小心地移动隐藏的点文件以及常规的可见文件,并且不想破坏 中已有的任何文件~/.vim/,请执行以下操作:
for A in $( find -mindepth 1 -maxdepth 1 ~/.vim/_vim ) ; do B=$( basename $A ) ; mv -iv ~/.vim/_vim/$B ~/.vim/ ; done
Most likely, you will wish to follow that with rmdir ~/.vim/_vim.
最有可能的是,您希望使用rmdir ~/.vim/_vim.
See also @Dunes' suggestions in the comments below.
另请参阅下面评论中@Dunes 的建议。
回答by Paul R
$ mv ~/.vim/_vim/* ~/.vim/
$ rmdir ~/.vim/_vim

