pistacchio
pistacchio

Reputation: 58863

Redirecting grep output to file

If I execute

$ java -jar selenium-server.jar 2>&1 | grep "jetty.Server" 

I get, after a while, the output I expect:

$ 16:30:24.881 INFO - Started org.openqa.jetty.jetty.Server@6b0a2d64

But I i try to redirect grep output to a file, it doesn't write a thing

$ java -jar selenium-server.jar 2>&1 | grep "jetty.Server" > /tmp/ebook_selenium

Any idea why? Thanks

Upvotes: 3

Views: 2148

Answers (1)

Adam Liss
Adam Liss

Reputation: 48290

We found that grep flushes its output when it writes to stdout but not to a file.

grep --line-buffered will force grep to output each line as it's processed.

Upvotes: 6

Related Questions