newcat
print (cat) only new lines in files (after previous run of newcat). This is useful to parse recent log records.
Install
pipx install newcat
Example
$ echo This is line 1 > /tmp/test.log
# works like normal /bin/cat now
$ newcat /tmp/test.log
This is line 1
# only new lines are printed
$ echo This is line 2 >> /tmp/test.log
$ newcat /tmp/test.log
This is line 2
# no new lines => nothing on stderr
$ newcat /tmp/test.log
# despite file is having two lines
$ cat /tmp/test.log
This is line 1
This is line 2
How does this magic work?
newcat stores some info about file (including position in file) in state file. Default state file is /tmp/.newcat.state, but can be overriden with NEWCAT_STATE environment variable or -s / --state option. Normally, newcat prints file content starting from this position (which was saved before), thus lines which were already printed before, will not be printed on new newcat run.
Sometime file content it rewritten (e.g. after echo New content > /tmp/test.log). To detect this situation newcat checks two things:
- file inode changed
- file size is less then old printed position
if any of these conditions are met, file considered as rewritten and newcat prints it from the beginning. Note: this is not absolutely reliable, and there is a chance that sometimes newcat will not detect when file is overwritten.
Metadata
Release files for newcat 0.0.1
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 | |
|---|---|---|---|---|
| newcat-0.0.1.tar.gz | 2.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| newcat-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.5 kB
Release files / newcat-0.0.1.tar.gz
| Download URL | newcat-0.0.1.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c8defe690bc858759d0e222e398d20b8a9ab2530ebf96b7db45e6a6ba5c7106c
|
|
BLAKE2b-256 checksum How to use checksums |
aa391ae84436be14d9f7c32ed67f1ff1b65f25bf1f61b2db852fa9580513cd25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.2
|
Release files / newcat-0.0.1-py3-none-any.whl
| Download URL | newcat-0.0.1-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8a9623dd610085ddbdcabef99132278bcc2e887f402a8a46f398293288bdca15
|
|
BLAKE2b-256 checksum How to use checksums |
07bf6068a2e5c88ce97ad797ede01b6f625dbcfb2dcc42088993b201965c778f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.2
|
Security for newcat 0.0.1
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.