Skip to content

wangxingwei1024/searchlargefile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

searchlargefile

简介

这是一个用python编写的查找目录下大文件的工具

所用模块

  • python模块:json,subprocess,optparse
  • 命令行工具:ncdu

实现方式

通过python的subprocess模块执行调用shell执行命令“ncdu -o - [dir]” 生成json格式的字符串,利用json将字符串转换成列表,列表具有多层次,类似一个多叉树,递归的遍历所有接节点,将文件节点的名字作为key文件大小作为value放入字典,根据字典的value进型倒叙,找出靠前的文件

开发环境

CentOS Linux release 7.4.1708 (Core) Python 2.7.5

使用方法

安装

git clone  https://github.com/baijuminglu/searchlargefile.git
cd searchlargefile
sh init.sh

使用

# 默认查找/ 目录最大的5个文件
./searchlargefile.py
#查找/ 目录最大10个文件
./searchlargefile.py -n 10
# 查找其他目录
./searchlargefile.py -d  /tmp

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published