How can I search patterns in Screen with a Perl regex?
-
03-07-2019 - |
Question
I have a process which gives me continuously output in Screen. I want to search CamelCase words by the following Perl's regex in the output such that I can monitor actively the outputs.
/\b([a-z]*[A-Z][a-z]*){2,}\b/
Solution
I tested in GNU/Screen and checked the source code. Both suggest that this is not possible. The search feature appears to support basic string matching only.
What I suggest is that you use the tee
command to send your program's output to a file in addition to printing it. You can use Perl or grep on the file after that.
$ your_program | tee your_program_output
$ grep pattern your_program_output
OTHER TIPS
Yes, capture the output and search that. gnu/screen isn't the right tool for capturing data and plenty of things can go wrong with this. But obviously you can still run it inside a screen session.
if you have already run the program inside screen without tee and prefer not to run it again, assuming your scrollback buffer is large enough, you can copy the entire scrollback buffer to a file and then search with your favorite method.