tail
文件tail工具。引入“偏移量文件”记录文件读取信息,支持文件内容断续读取。
安装
pip install tail
安装的命令
- pytail
注意:
- 在python模块、方法中,均使用tail名称。
- tail是linux的常用命令,一般发行版中必然都已经安装。
- 提供的console程序,命名为pytail,防止这种冲突。
命令帮忙信息
E:\tail>pytail --help
Usage: tail [OPTIONS] FILENAME
文件tail工具。引入“偏移量文件”记录文件读取信息,支持文件内容续读。
Options:
-o, --offset-file TEXT 偏移量文件路径。默认为:在文件名后加.offset后缀。
-x, --read-from-end 如果不存在偏移量文件的话,指定该参数后则从文件的最后开始读取;不指定该参数的话则从文件开
始读取。
-e, --file-encoding TEXT 文件读取编码,默认为utf-8。
-p, --backup-patterns TEXT 文件可能通过logrotate等方式被备份出来,通过inode识别这些文件,先读取完备份
文件中的剩余内容,再读取新文件内容。
-s, --sleep-interval INTEGER 读完文件后,休息一段时间后再续读。休息时间单位为:秒,默认为1秒。
-u, --update-offset-every-n INTEGER
每读取指定行后,更新偏移量文件。默认为100行。
-n, --non-blocking 指定该参数后,表示读取完文件内容后直接退出,同时sleep-
interval参数无效;不指定的话则休眠sleep-interval秒后重新续读。
--help Show this message and exit.
命令安全案例
E:\tail>type a.txt
line 1
line 2
line 3
E:\tail>pytail -n a.txt
line 1
line 2
line 3
E:\tail>echo line 4 >> a.txt
E:\tail>echo line 5 >> a.txt
E:\tail>pytail -n a.txt
line 4
line 5
- 读取a.txt全部文件内容并显示,读完后退出,生成a.txt.offset偏移量文件。
- 在a.txt中追加line 4、line 5两行内容。
- 根据a.txt.offset偏移量文件进行续读,显示第4、5两行。
tail模块公开的类、方法
- TailReader 核心文件处理类。
- print_line 行处理方法。在屏幕上打印行,文件readline后的带上的\r\n字符。
- tail TailReader的包装方法。
Metadata
Release files for tail 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| tail-0.1.12.tar.gz | 5.0 kB | Without provenance | Details |
Release files / tail-0.1.12.tar.gz
| Download URL | tail-0.1.12.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4b85991253be22d52e09f1a8c6000dc7bcb22bd2a742d8d87d6e1967ccd5c54e
|
|
BLAKE2b-256 checksum How to use checksums |
24d150b95d3f025aa48a2598773e574a209721526c43f224b9cabb38dffb6a31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3
|
Security for tail 0.1.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.