我试图删除一个目录中的所有文件,但在这个目录中保留了两个文件。
我使用命令
rm !(1file name| 2filename)
但它抛出错误
bash: !: event not found
请帮我纠正这个命令。
!
尝试展开历史事件。在BASH中,您可以使用:启用extglob
shopt -s extglob
然后使用此rm
命令删除除以下两个列出的文件外的所有文件:
rm !(@(filename1|filename2))