johnpoint

johnpoint

(。・∀・)ノ゙嗨
github

Linux 删除大量文件

最近去看了下我的自动重连脚本的 log 文件夹

image

文件太多, rm 命令会提示参数太多不能执行

于是写了个 python 脚本来删除文件

import os
for pathname,dirnames,filenames in os.walk('/root'):
     for filename in filenames:
         if 'net.log' in filename:
             file=os.path.join(pathname,filename)
             os.remove(file)
print("OK")
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.