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 applicationless
. You can do so using the forward slash (/
) followed by whatever string you're searching for. Hit return to execute the search.Example
grep
In the same vain as above with using
less
, you can also use tools such astail
to print the lats few lines of a applications log file messages, and also usegrep
to search for only lines that contain a matching string/pattern.