1个不稳定版本
| 0.1.0 | 2023年5月26日 |
|---|
在 文件系统 中排名第1254
23KB
526 代码行
sz
以实用方式查看您的文件大小。将其视为比du核心工具更容易使用且更直观的替代品。
该项目仍在开发中,可能包含错误和糟糕的代码!如果您发现任何问题,请提交问题/PR。
用法
让我们看看如何在目录中使用这个实用工具。
- 查找当前目录的大小(不包括gitignored和隐藏文件/在gitignored或隐藏目录中的文件)
sz .
这将输出结果

file/dir name | size
---------------+---------
sz | 41.52KB
10 files parsed
- 如果您想列出每个文件的大小以及文件路径
sz . -l

- 可以通过包括
-g和-i标志分别包括gitignored和隐藏标志。
sz . -l -i -g

- 如果您在包含超过50个文件的目录中运行此命令,它将只显示前20个。您可以通过提供要列出的项目数使用
-n参数,或者包括-L标志来列出所有项目。
sz . -l -i -g -n 30 # show me the first 30 items
sz . -l -i -g -L # show me all the files
- 您还可以使用
-d和-a标志根据大小对项目进行排序。
sz . -l -d -n 5 # returns the 5 largest files in the current directory

sz . -l -a -n 6 # returns the 6 smallest files in the current directory

- 要仅查看路径中的根目录,请使用
-D标志。此标志将仅显示与提供的路径相同的父目录的目录。它不会列出任何文件。
sz ~/Documents/rl -l -D

- 通过提供
-R标志,您可以递归地查看路径中的所有目录。
sz ~/Documents/rl -l -D -R

请注意,您也可以使用之前提到的所有选项与-D标志。
# shows the 3 largest directories in this path (including gitignored or hidden)
sz ~/Documents/rl -l -D -R -i -g -d -n 3

- 使用
-e标志排除目录
sz ~/Documents/rl -l -D -R -d -e ~/Documents/rl/public/ ~/Documents/rl/assets/

警告:此参数实际上不与-i或-g一起工作
- 使用
-s标志显示解析的所有文件的总行数。显然,仅对UTF-8编码的文件运行此操作。
sz ./src -l -s

选项
选项很简单但功能强大
Options:
-d, --sort-files-desc Sort items by size in descending order
-a, --sort-files-asc Sort items by size in ascending order
-i, --include-hidden Include hidden files
-l, --list-files List the files in the directory
-L, --list-all List all files in the directory even if directory count exceeds 50
-g, --include-gitignored Include gitignored files
-e, --exclude-dirs <EXCLUDE_DIRS>... Directories to exclude
-n, --num-files <NUM_FILES> Number of files to list
-D, --only-dirs Show only directories
-R, --recursive-dirs Recursively list directories (Only to be used with -D flag)
-s, --show-lines Show total line count for items
-h, --help Print help
运行sz -h查看此帮助消息。
依赖关系
~11–21MB
~304K SLoC