Pawan
Pawan

Reputation: 32331

Is it possible to search when the file is opened using tail -f option

I opened a log file using tail -f mylog.log , can i do a search for a particular string during this time ??

Means when the application is running , and i opened the log using the tail command , is it possible to search for a particular key in that log ??

Thanks

Upvotes: 4

Views: 4596

Answers (3)

dogbane
dogbane

Reputation: 274630

I don't think tail can do this.

Instead of tail -f, use less +F which has the same behaviour. Then you can press Ctrl+C to stop tailing and use ? to search backwards. To continue tailing the file from within less, press F.

Upvotes: 3

Paul Alan Taylor
Paul Alan Taylor

Reputation: 10680

Yes.

Pipe it into grep.

tail -f | grep searchstring

Upvotes: 0

ScoPi
ScoPi

Reputation: 1183

If you are asking if the file can be read by another process, yes, it can. In other words, if, for example, you search the file from another shell instance, it will work even while another instance is tail -f'ing it.

Upvotes: 0

Related Questions