3 ms·
You also can't follow a file with grep, but you can with tail. Doing so requires the grep option "--line-buffered", which sacrifices some performance, but not
by ynniv 17y ago
You also can't follow a file with grep, but you can with tail. Doing so requires the grep option "--line-buffered", which sacrifices some performance, but not much compared to actually viewing the log data.
tail -f access.log | grep --line-buffered "GET /blog/post "
- randallsquared 17y agoI do this a lot, and I've never used "--line-buffered", nor apparently needed it. Google shows me a lot of people using that as a solution to a problem (not getting results immediately) I've never seen. Weird.
- ynniv 17y agoI only started using it because results were not appearing in "real-time", so it may depend on your OS, or your definition of "real-time".
- silentbicycle 17y agoIt's more likely if you have grep and several other operations piped together - the normal buffering leads to grep only printing every time it gets a full block of data, typically several lines.