Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Is there a easy way for me to:

  • search for a string in the output window of the putty ?
  • or even a Linux command to search and highlight a string in the output ?

I have 20,000+ lines in the output and sometimes I have to search for customer_id : 1111 and currently I have to copy them to word or notepad and then search.

Is there a better way to do this ?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

If you don't care about the rest of the output, then

yourcommand | grep "some regular expression"

will only print the lines that contain "some regular expression".

yourcommand | less

will send the output of your command to the less command which lets you scroll up and down the output. You can search by typing /some regular expression and pressing enter. q will close the program.

If you do want to save the file, then

yourcommand > outputfile

will send the output to a file instead of the screen, which you can open in an editor and search instead of displaying it on the screen. If it exists, outputfile will be erased before yourcommand runs. You can add the output to the end of an existing file if you use >> instead.

The tee program lets you save the output to a file and send it to another program at the same time:

yourcommand | tee outputfile | somethingelse

This will save the original output to outputfile and pass it to some other command.

share|improve this answer
    
And on the grep, if its gnu grep, you can do grep --color foo to highlight foo. This is useful if your lines are really long and you need to see where in the line the match is at. –  Patrick Jul 26 '12 at 3:20

I'd suggest that in the future you enable PuTTY logging, ensuring the log size is appropriate. Doing that you can use any half decent text editor to open the log and search for any part of the text you desire, whether it's your input or the remote system's output.

share|improve this answer

To search for characters in the file:

$ more YourFile

then you type / and type the character you are looking for:

eg: /a

share|improve this answer
1  
This doesn't seem to be answering the question. The OP doesn't want to find text in a file. He wants to find text in the scroll back buffer in PuTTY. –  Ladadadada Jan 3 at 15:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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