Search text in command output on a PuTTY terminal

puttysearchterminal

I would like to know how to search particular text on the terminal. If I do cat of log files, I would like to find certain words like job or summary so that I don't have to read through the entire log file.

I know there have been a similar post about this. The answer from that post is Ctrl + A + [ <text> which doesn't seem to work for me. When I press that I get a message No bracket in top line (press Return) or If I press those keys together I get the message ESC.

It there a way to do this with PuTTY? Alternatively, is there a generic way to search for text in the output of commands?

Best Answer

The Ctrl + a + [ is meant for use within the application screen (an app for multiplexing consoles).

less

Generally the easiest method to do this is to use tools such as less and to pipe the output from whatever application is generating the messages on the console, and search within the application less. You can do so using the forward slash (/) followed by whatever string you're searching for. Hit return to execute the search.

Example

$ less filename.log

...then in less, type a forward slash followed by string to search, foo

grep

In the same vain as above with using less, you can also use tools such as tail to print the lats few lines of a applications log file messages, and also use grep to search for only lines that contain a matching string/pattern.

$ grep "somestring" filename.log