Search text in command output on a PuTTY terminal
Solution 1
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
Solution 2
You can also right click the title bar at the top of the window and select Copy All to Clipboard, then paste into a text editor and use that to search.
Related videos on Youtube
Ashwin
Updated on September 18, 2022Comments
-
Ashwin over 1 year
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 messageNo bracket in top line (press Return)
or If I press those keys together I get the messageESC
.It there a way to do this with PuTTY? Alternatively, is there a generic way to search for text in the output of commands?
-
Jeff Hewitt over 10 yearsIt helps if you tell us which terminal emulator you're using.
-
slm over 10 yearsWhat are the commands you're looking to search output from? Just general commands or is there a log file that a server/service is writing messages to that you want to search through?
-
jordanm over 10 years
konsole
supports this with ctrl+shift+f
-
-
Ashwin over 10 yearsI didnt quite get it. After I do cat filename.log | less how can I find particular text from the whole screen, if at all its possible.
-
Ashwin over 10 yearsCool this is what I was looking for. I can find it by executing cat filename.log | grep Summary or less filename
-
slm over 10 years@Ashwin - glad it worked for you, see my updates, for shorter versions of using both tools so you can skip having to use
cat
. -
Mahender Reddy Yasa about 6 yearshow to search for next number 2 search item(for ex second "error" in file)
-
slm about 6 years@MahenderY - if you have follow up questions please ask them on the main site and reference this Q&A within them.