I have a program that outputs some data to the terminal (via printf() ). Is it possible search a text on the outputed text on the terminal directly?

It is possible to do search by directing the texts into a file then make search on it then output the result to the terminal, but it is not what I am asking.

EDIT: what I meant by "search": I wonder if it is possible to search a text, for example how can I search libgnome-desktop on the below terminal output?

enter image description here

  • 2
    Are you looking for a terminal that supports this, or a way to do it in your current terminal? rxvt has this Aug 9, 2013 at 21:22
  • @Michael Mrozek: I would like to know if a terminal (especially ubuntu's terminal) has such functionality to search a text. If it is the case, how can I do it.
    – Angs
    Aug 9, 2013 at 21:24

3 Answers 3


You could use the terminal multiplexer tmux to run your program in any terminal. Then you can search through the window entering copy mode with Ctrl-b [, and use emacs (Ctrl-s) or vi (/) keywords to search for a string depending on whether emacs or vi mode is selected.

The keys available to exit copy mode are Esc or Enter for different versions of tmux.

Alternatively, some terminals support searching the window buffer, like urxvt with the searchable-scrollback Perl extension.


If you were using screen, then you could go to copy mode Ctrl+a [ and then type: ?libgnome-desktop To keep searching for more instances press n for next and N for previous instance of searched string. To exit copy mode press Esc.

Additionally with screen you could press space when in copy mode to start highlighting text and press space again to copy that highlighted text. This could be pasted at the prompt or anywhere else on the terminal input with Ctrl+a ].

  • See also C-A h to dump the current screen into a file and C-A : hardcopy -h to also include the scroll buffer in that dump. Aug 10, 2013 at 7:16

By search you mean what? find, grep or something else?

You can put the output of your printf as an argument to another command via the $() syntax

grep "$(printf "%s" 'foo')" file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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