Can ugrep.exe search files that another process on Windows has open for writing? #473
-
I have an application which writes log files whilst it runs. I can search those files using (GNU) grep.exe whilst the app is still running but ugrep just reports "No such file or directory". These files are large (1GB+) so I'd really prefer to use ugrep over grep. Also there is an option to generate them as gzip compressed files which saves loads of diskspace but grep can't handle them (and I haven't found a good zgrep for Windows - that search is what led me to ugrep). Have used ag.exe in the past but really looking for something that is commandline compatible with grep as far as possible since I spend most of my time on Linux. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Thank you for your feedback. Read/write clashes between processes as not uncommon on Windows, whereas Unix/Linux it's never an issue. I believe a small change to the Windows CreateFileW(wfilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL) should also allow CreateFileW(wfilename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL) I'll verify this and fold it into the next release. |
Beta Was this translation helpful? Give feedback.
-
I've made a tiny update and recompiled the ugrep.exe v7.3 files located in the repo bin dirs: https://github.com/Genivia/ugrep/tree/master/bin/win64 Tested as follows in cmd.exe:
then leave that open and start new cmd.exe to search with So this should work. If an error occurs, then it the other process prevents the file from being read when it writes it, or it deleted the file, or other manipulations prevents read access. |
Beta Was this translation helpful? Give feedback.
I've made a tiny update and recompiled the ugrep.exe v7.3 files located in the repo bin dirs: https://github.com/Genivia/ugrep/tree/master/bin/win64
Tested as follows in cmd.exe:
then leave that open and start new cmd.exe to search with
ugrep.exe test testcon.txt
which returnstest
.So this should work. If an error occurs, then it the other process prevents the file from being read when it writes it, or it deleted the file, or other manipulations prevents read access.