# shopt -s extglob (打开extglob模式) # rm -rf !(file1) 如果是多个要排除的,可以这样: # rm -rf !(file1|file2) 转载于:https://www.cnblogs.com/FlyHeLanMan/p/7543374.html