转载自:http://binnchx.leanote.com/post/linux-mv命令排除某个文件或文件夹
参考:How to use ‘mv’ command to move files except those in a specific directory?
假设目录结构如下:
|parent
|--child1
|--child2
|--grandChild1
|--grandChild2
|--grandChild3
|--grandChild4
|--grandChild5
|--grandChild6
现在要改为:
|parent
|--child1
| |--grandChild1
| |--grandChild2
| |--grandChild3
| |--grandChild4
| |--grandChild5
| |--grandChild6
|--child2
实现命令如下:
mv !(child1|child2) child1
若遇到
-bash: !: event not
错误,请执行
shopt -s extglob