# 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
~~~bash
$ 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/yaroslaff/newcat",
"name": "newcat",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "",
"keywords": "",
"author": "Yaroslav Polyakov",
"author_email": "yaroslaff@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/aa/39/1ae84436be14d9f7c32ed67f1ff1b65f25bf1f61b2db852fa9580513cd25/newcat-0.0.1.tar.gz",
"platform": null,
"description": "# newcat\n\nprint (cat) only new lines in files (after previous run of newcat). This is useful to parse recent log records.\n\n## Install\n~~~\npipx install newcat\n~~~\n\n## Example\n~~~bash\n$ echo This is line 1 > /tmp/test.log\n\n# works like normal /bin/cat now\n$ newcat /tmp/test.log \nThis is line 1\n\n# only new lines are printed\n$ echo This is line 2 >> /tmp/test.log\n$ newcat /tmp/test.log \nThis is line 2\n\n# no new lines => nothing on stderr\n$ newcat /tmp/test.log \n\n# despite file is having two lines\n$ cat /tmp/test.log \nThis is line 1\nThis is line 2\n~~~\n\n## How does this magic work?\nnewcat 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.\n\nSometime file content it rewritten (e.g. after `echo New content > /tmp/test.log`). To detect this situation newcat checks two things:\n- file inode changed\n- file size is less then old printed position\n\nif any of these conditions are met, file considered as rewritten and newcat prints it from the beginning.\nNote: this is not absolutely reliable, and there is a chance that sometimes newcat will not detect when file is overwritten.\n\n\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "print / cat only new lines in log files",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/yaroslaff/newcat"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "07bf6068a2e5c88ce97ad797ede01b6f625dbcfb2dcc42088993b201965c778f",
"md5": "db9e85da196ae62fdaccf6d7f76c0373",
"sha256": "8a9623dd610085ddbdcabef99132278bcc2e887f402a8a46f398293288bdca15"
},
"downloads": -1,
"filename": "newcat-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "db9e85da196ae62fdaccf6d7f76c0373",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3572,
"upload_time": "2023-10-29T15:50:32",
"upload_time_iso_8601": "2023-10-29T15:50:32.600926Z",
"url": "https://files.pythonhosted.org/packages/07/bf/6068a2e5c88ce97ad797ede01b6f625dbcfb2dcc42088993b201965c778f/newcat-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "aa391ae84436be14d9f7c32ed67f1ff1b65f25bf1f61b2db852fa9580513cd25",
"md5": "f05a977930b4c45ac05330bdcc05b1e1",
"sha256": "c8defe690bc858759d0e222e398d20b8a9ab2530ebf96b7db45e6a6ba5c7106c"
},
"downloads": -1,
"filename": "newcat-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "f05a977930b4c45ac05330bdcc05b1e1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 2899,
"upload_time": "2023-10-29T15:50:34",
"upload_time_iso_8601": "2023-10-29T15:50:34.360549Z",
"url": "https://files.pythonhosted.org/packages/aa/39/1ae84436be14d9f7c32ed67f1ff1b65f25bf1f61b2db852fa9580513cd25/newcat-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-29 15:50:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yaroslaff",
"github_project": "newcat",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "newcat"
}