The standard output stream (stdout) is the stream where a program writes its output data.
Questions tagged [stdout]
4740 questions
1945
votes
9 answers
How to redirect and append both standard output and standard error to a file with Bash
To redirect standard output to a truncated file in Bash, I know to use:
cmd > file.txt
To redirect standard output in Bash, appending to a file, I know to use:
cmd >> file.txt
To redirect both standard output and standard error to a truncated…

flybywire
- 261,858
- 191
- 397
- 503
1521
votes
11 answers
How to redirect output to a file and stdout
In bash, calling foo would display any output from that command on the stdout.
Calling foo > output would redirect any output from that command to the file specified (in this case 'output').
Is there a way to redirect output to a file and have it…

SCdF
- 57,260
- 24
- 77
- 113
1241
votes
11 answers
How can I pipe stderr, and not stdout?
I have a program that writes information to stdout and stderr, and I need to process the stderr with grep, leaving stdout aside.
Using a temporary file, one could do it in two steps:
command > /dev/null 2> temp.file
grep 'something' temp.file
But…
user80168
847
votes
15 answers
Redirect stderr and stdout in Bash
I want to redirect both standard output and standard error of a process to a single file. How do I do that in Bash?

flybywire
- 261,858
- 191
- 397
- 503
660
votes
16 answers
Disable output buffering
Is output buffering enabled by default in Python's interpreter for sys.stdout?
If the answer is positive, what are all the ways to disable it?
Suggestions so far:
Use the -u command line switch
Wrap sys.stdout in an object that flushes after every…

Eli Bendersky
- 263,248
- 89
- 350
- 412
627
votes
10 answers
logger configuration to log to file and print to stdout
I'm using Python's logging module to log some debug strings to a file which works pretty well. Now in addition, I'd like to use this module to also print the strings out to stdout. How do I do this? In order to log my strings to a file I use…

stdcerr
- 13,725
- 25
- 71
- 128
508
votes
16 answers
The difference between sys.stdout.write and print?
Are there situations in which sys.stdout.write() is preferable to print?
(Examples: better performance; code that makes more sense)

Johanna Larsson
- 10,531
- 6
- 39
- 50
446
votes
32 answers
Displaying Windows command prompt output and redirecting it to a file
How can I run a command-line application in the Windows command prompt and have the output both displayed and redirected to a file at the same time?
If, for example, I were to run the command dir > test.txt, this would redirect output to a file…
Ammu
428
votes
14 answers
Redirect stdout to a file in Python?
How do I redirect stdout to an arbitrary file in Python?
When a long-running Python script (e.g, web application) is started from within the ssh session and backgounded, and the ssh session is closed, the application will raise IOError and fail the…
user234932
373
votes
12 answers
Setting the correct encoding when piping stdout in Python
When piping the output of a Python program, the Python interpreter gets confused about encoding and sets it to None. This means a program like this:
# -*- coding: utf-8 -*-
print u"åäö"
will work fine when run normally, but fail…

Joakim Lundborg
- 10,920
- 6
- 32
- 39
361
votes
5 answers
How to redirect both stdout and stderr to a file
I am running a bash script that creates a log file for the execution of the command
I use the following
Command1 >> log_file
Command2 >> log_file
This only sends the standard output and not the standard error which appears on the terminal.

sdmythos_gr
- 5,444
- 3
- 25
- 25
304
votes
11 answers
Confused about stdin, stdout and stderr?
I am rather confused with the purpose of these three files. If my understanding is correct, stdin is the file in which a program writes into its requests to run a task in the process, stdout is the file into which the kernel writes its output and…

Shouvik
- 11,350
- 16
- 58
- 89
302
votes
5 answers
How to pipe stdout while keeping it on screen ? (and not to a output file)
I would like to pipe standard output of a program while keeping it on screen.
With a simple example (echo use here is just for illustration purpose) :
$ echo 'ee' | foo
ee <- the output I would like to see
I know tee could copy stdout to file but…

gentooboontoo
- 4,653
- 3
- 20
- 15
281
votes
18 answers
How can I print multiple things on the same line, one at a time?
I want to run a script, which basically shows an output like this:
Installing XXX... [DONE]
Currently, I print Installing XXX... first and then I print [DONE].
How can I instead print Installing xxx... and [DONE] on the same…

user697108
- 3,521
- 3
- 20
- 14
273
votes
12 answers
Command to get nth line of STDOUT
Is there any bash command that will let you get the nth line of STDOUT?
That is to say, something that would take this
$ ls -l
-rw-r--r--@ 1 root wheel my.txt
-rw-r--r--@ 1 root wheel files.txt
-rw-r--r--@ 1 root wheel here.txt
and do something…

Alana Storm
- 164,128
- 91
- 395
- 599