strongwillow
strongwillow

Reputation: 338

How to redirect(pipe) a log file to console?

I have a log file, which can only be appended to. I want to pipe this log file to console, so that once new data comes to the log file, the console also reflects the new piece of data. When there is no data to be appended, the console should block there waiting for updates.

It's like a proxy server, redirecting file updates to console.

How to achieve this using bash?

Thank you.

Upvotes: 0

Views: 977

Answers (2)

Kamath
Kamath

Reputation: 4674

tail command should work for you.

tail -f <log file>

Upvotes: 1

Aleks-Daniel Jakimenko-A.
Aleks-Daniel Jakimenko-A.

Reputation: 10663

Use tail:

tail -f logfile

-f means follow which is exactly what you need.

Also, in case you run into some problems with file becoming inaccessible, try using -F

Upvotes: 1

Related Questions