AKSHIT AKSHIT - 1 year ago 82
Linux Question

Grep on a file that is being written by another application

I am using grep to match a string in a file but at the same time another application might be writing to the same file.

In that case what will grep do.

Will it allow the file to being written by other application or will it not give access to the file?

Also if it does give access will my grep results be based on before the file was written or after?

Basically I want the grep to not lock the access to the file but if it does that is their an alternative to prevent it from doing so..

My Sample command:
egrep -r -i "regex" /directory/*

Answer Source

grep does not lock the file, so it is safe to use it, while the file is being actively used by another application

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download