Questions tagged [stdout]

stdout is the name of the default output file descriptor of a process. Since there is nothing special about `stdout`, you *should not* use this tag. Use the [io-redirection] tag for questions on how to redirect output, use [file-descriptors] for questions on how to manage file descriptors, use [lock] for questions of file locking, and use [files] for general questions on file operations.

stdout is the name of the default output file descriptor of a process. Since there is nothing special about stdout, you should not use this tag. Use for questions on how to redirect output, use for questions on how to manage file descriptors, use for questions of file locking, and use for general questions on file operations.

471 questions
107
votes
5 answers

Do progress reports/logging information belong on stderr or stdout?

Is there an official POSIX, GNU, or other guideline on where progress reports and logging information (things like "Doing foo; foo done") should be printed? Personally, I tend to write them to stderr so I can redirect stdout and get only the…
terdon
  • 234,489
  • 66
  • 447
  • 667
104
votes
10 answers

How to do nothing forever in an elegant way?

I have a program which produces useful information on stdout but also reads from stdin. I want to redirect its standard output to a file without providing anything on standard input. So far, so good: I can do: program > output and don't do anything…
a3nm
  • 8,978
  • 5
  • 28
  • 36
92
votes
7 answers

Can I pipe stdout on one server to stdin on another server?

stdout on one CentOS server needs to be piped to stdin on another CentOS server. Is this possible? Update ScottPack, MikeyB and jofel all have valid answers. I awarded the answer to Scott because, even though my question didn't specify security as a…
Wesley
  • 13,963
  • 12
  • 35
  • 49
85
votes
6 answers

Can I configure my shell to print STDERR and STDOUT in different colors?

I want to set my terminal up so stderr is printed in a different color than stdout; maybe red. This would make it easier to tell the two apart. Is there a way to configure this in .bashrc? If not, is this even possible? Note: This question was…
Naftuli Kay
  • 38,686
  • 85
  • 220
  • 311
79
votes
4 answers

Write Python stdout to file immediately

When trying to write the stdout from a Python script to a text file (python script.py > log), the text file is created when the command is started, but the actual content isn't written until the Python script finishes. For example: script.py: import…
Bart
  • 890
  • 1
  • 7
  • 9
76
votes
7 answers

How to trick a command into thinking its output is going to a terminal

Given a command that changes its behaviour when its output is going to a terminal (e.g. produce coloured output), how can that output be redirected in a pipeline while preserving the changed behaviour? There must be a utility for that, which I am…
Amir
  • 1,531
  • 1
  • 14
  • 18
76
votes
9 answers

How to add new lines when using echo

Why does the following command not insert new lines in the generated file and what's the solution? $ echo "Line 1\r\nLine2" >> readme.txt $ cat readme.txt Line 1\r\nLine2
Dumbo
  • 1,516
  • 6
  • 16
  • 20
72
votes
5 answers

Output file contents while they change

I want to output a file's contents while they change, for example if I have the file foobar and I do: magic_command foobar The current terminal should display the file's contents and wait until, I don't know, I press ^C. Then if from another…
Paul
  • 823
  • 1
  • 6
  • 6
58
votes
8 answers

How do I send stdout to the clipboard?

Is there functionality in Unix that allows for the following: echo "Some Text" | copy-to-clipboard
Stefan
  • 24,830
  • 40
  • 98
  • 126
49
votes
8 answers

Command to output file content to stdout?

I know cat can do this, but its main purpose is to concatenate rather than just to display the content. I also know about less and more, but I'm looking for something simple (not a pager) that just outputs the content of a file to the terminal and…
confused00
  • 798
  • 1
  • 7
  • 13
47
votes
3 answers

Direct output to pipe and stdout

Is there a way to pipe the output of a command and direct it to the stdout as well? So for example, fortune prints a fortune cookie to stdout and also pipes it to next command: $ fortune | tee >(?stdout?) | pbcopy "...Unix, MS-DOS, and Windows NT…
user14492
  • 753
  • 1
  • 8
  • 15
40
votes
5 answers

How to invoke vim editor and pipe output to bash

Sometimes I need to write text and then pipe that text into another command. My usual workflow goes something like this: vim # I edit and save my file as file.txt cat file.txt | pandoc -o file.pdf # pandoc is an example rm file.txt I find this…
theideasmith
  • 600
  • 1
  • 4
  • 10
40
votes
2 answers

In bash script, how to capture stdout line by line

In a bash script, I would like to capture the standard output of a long command line by line, so that they can be analysed and reported while initial command is still running. This is the complicated way I can imagine of doing it: # Start long…
gfrigon
  • 503
  • 1
  • 4
  • 7
36
votes
6 answers

How do I make python programs behave like proper unix tools?

I have a few Python scripts laying around, and I'm working on rewriting them. I have the same problem with all of them. It's not obvious to me how to write the programs so that they behave like proper unix tools. Because this $ cat characters |…
ixtmixilix
  • 13,040
  • 27
  • 82
  • 118
35
votes
4 answers

Output to stdout and at the same time grep into a file

I have a script that outputs text to stdout. I want to see all this output in my terminal, and at the same time I want to filter some lines and save them in a file. Example: $ myscript Line A Line B Line C $ myscript | grep -P 'A|C' > out.file $…
lorenzo-s
  • 596
  • 1
  • 8
  • 10
1
2 3
31 32