Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have written a program that outputs a lot of text to the terminal.

I am looking for certain words in the text to see if I have done it right, but simply reading the text is impossible.

Are there any capabilities or commands that can actually enable me to lookup a word in the terminal (like Ctrl + F)?

share|improve this question
    
what is the right command to add a word or phrases in text file using terminal? –  user10996 Feb 17 '11 at 10:17

5 Answers 5

up vote 33 down vote accepted

It's Shift + Ctrl + F.

You might want to change the Scrollback value to Unlimited to not lose any lines:

  • Edit > Profile Preferences > Scrolling

    enter image description here

share|improve this answer
8  
Rule of thumb: Shift + Shortcut will work for the most part –  jrg Feb 3 '11 at 11:43
    
Can this be achieved in Lubuntu? It seems it cannot –  pablofiumara Nov 24 '13 at 19:36

You could pipe the output to a file with > myfile.txt And then search the file with grep.

grep "word" myfile.txt

I usually prefer this approach as you don't need to worry about the terminal buffer size, and you can easily keep output from multiple runs of program.

share|improve this answer

Another option:

yourCommand | less

Now, you can press the arrow keys to go up,down, left and right (usually you only use the first two).

You can also type /word so search for a word (or a regex) after the cursor. Conversely, ?word will search the word/regex before (above) the cursor. (Cursor is the position where you are in the text.)

You can also use Home and End keys to go to the start and end of the output. Pressing Q will make you Quit (returning to the console).

More info:

man less
share|improve this answer
mycommand | grep "phrase I want to find"

This eliminates @Alb's^ intermediary step of redirecting to a file.

share|improve this answer

If you use GNU Screen - copy mode and jk works fine.

share|improve this answer

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.