YOU*_*YOU 0 regex linux bash rm delete-file
我有一个文件夹,其中包含一些文件扩展名,我想删除除html扩展名以外的所有内容.谁能帮我?
Fat*_*ror 10
使用bash的extglob功能.要启用它,如果它尚未打开:
shopt -s extglob
Run Code Online (Sandbox Code Playgroud)
然后你可以简单地否定glob:
rm !(*.html)
Run Code Online (Sandbox Code Playgroud)
您可以使用此find命令:
find /your/path -maxdepth 1 -type f ! -name '*.html' -delete
Run Code Online (Sandbox Code Playgroud)