Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am facing a slight problem in my project. I have a menu driven program and one of my options is Display all, which displays all the entries from a map using a loop. The display is on the terminal and I am not being able to view all the entries because it only shows the last few entries before my prompt comes again. I want the output to be redirected to a file so that I can use more commands and give the user a view accordingly. Please suggest few commands or code.

share|improve this question
When you say "menu driven" what do you mean? Is this a console or graphical program? What command do you use to launch the program? Does it have input/output arguments? – Caleb Jun 15 '11 at 11:04

You can set up a pipeline when you launch your program to write its output to a file.

$ your_program > /tmp/output.txt

If the program does other things with the output, such as prompt the user for input, it is likely that it uses the second output channel (the error channel) to show menus, so it is possible that this won't get in the way of normal operation and will only capture dump output.

Additionally, programs such as GNU screen and tmux come in very handy for this by allowing you to capture and look at the scroll back history from a window and even capture parts of it and log it to a file.

If that doesn't work, tell us more about your program and usage.

share|improve this answer
it is console based and i use default ./a.out to execute my program. 1..... 2..... 3.Display – newars Jun 15 '11 at 12:07
Does redirecting as above do the job? What else does your program output? If you wrote the program did you setup interface output on stderr and data output on stdout? – Caleb Jun 15 '11 at 12:31

You can redirect terminal output to a file using this syntax:

program params > fileName
share|improve this answer

Standard output (stdout):

command > file

or if you want to append:

command >> file

Standard error (stderr):

command 2> file

or if you want to append:

command 2>> file
share|improve this answer

Your Answer


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.