1

I am dumping some debug info into a text file that I am using tail -f to monitor.

Is there a tool that I can then pipe that tail -f data into to be able to search the text on-screen using regular expression commands, like search in vim?

  • see if the answers in unix.stackexchange.com/questions/25211/… can do what you want. the OP there wanted it to alert, but there's an example using regexes to match and beep. you could use the same regex matching, and have your own action. – Tim Kennedy Jul 27 '13 at 5:57
  • not quite I want to be able to explore the data not highlight something specific. I have all this async stuff flying around so other then searching through the output its a shot in the dark to find what I want. – MageProspero Jul 27 '13 at 6:03
7

Use less. Start less on the text file you want to monitor:

less some_file

If you want to search for a pattern, ues a slash to start a search a pattern:

/<pattern>  # forward search
?<pattern>  # backward search

If you want to filter the output use an ampersand:

&<pattern>

Then start the continuous output using shiftf. You can exit the continuous output display with ctrlc and refine or cancel your filter pattern or start a search.

  • This does not work if the file is truncated = / any advice on getting around this? – MageProspero Jul 27 '13 at 21:28
  • 1
    @JamesAndino Type :e Enter to reload the file if it has changed. – Gilles 'SO- stop being evil' Jul 27 '13 at 22:25
  • word im just being crazy ocd about my tools again aint i – MageProspero Jul 28 '13 at 2:37
0

If you can't find anything else, you could try seetxt, which can monitor and update a loaded file at configurable intervals (1 second granularity), and has PCRE searching.

Unfortunately it does too many other things as well; I wrote it about 5 years ago and it was my first "big" C project; the source is pretty ugly, lol, but it generally works with some caveats that shouldn't affect what you are doing unless the input is very large or contains a lot of odd characters.

That said, it's something I'd think about revamping for exactly this purpose if it's a niche that lacks. I generally just stop/start things and deal with static logs when debugging, but something that streamed input and did regexps is a good idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.