Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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 [tag:io-redirection] for questions on how to redirect output, use [tag:file-descriptors] for questions on how to manage file descriptors, use [tag:lock] for questions of file locking, and use [tag:files] for general questions on file operations.

25
votes
3answers
1k views

Is it safe to redirect stdout and stderr to the same file without file descriptor copies?

I start off in empty directory. $ touch aFile $ ls aFile Then I ls two arguments, one of which isn't in this directory. I redirect both output streams to a file named output. I use >> in order ...
1
vote
0answers
28 views

Curl download speed restricted when down/uploading from stdin/stdout

I'm running 2 curl commands where one downloads all the data into stdout/in until the stack is filled and another uploading whatever is in it out but it seems like the speed is restricted. For the ...
1
vote
1answer
20 views

`Convert` and standard output

I am learning how to use terminal and as an exercise tried to convert a bunch of .png images to ASCII-art using convert and jp2a with this command: convert test.png -format jpg - | jp2a - This ...
28
votes
5answers
2k views

How to redirect stdout to a file, and stdout+stderr to another one?

How can I achieve cmd >> file1 2>&1 1>>file2 That is, the stdout and stderr should redirect to one file (file1) and only stdout (file2) should redirect to another (both in append ...
0
votes
0answers
16 views

Display format of ls [duplicate]

When listing the files in a directory by running ls I see a sort of tabular format, with lines and columns. If I pipe this output into head, wc or any other program, it seems to interpret each file ...
4
votes
1answer
199 views

stdout and stderr redirection to different files

How can I redirect stdout to 2 different files and stderr to another, different file? I want something like <my_cmd> 1> file1 file2 2>file3 I know: <my_cmd> | tee file1 file2 > /...
0
votes
0answers
12 views

bifurcate stdout - Send stdout to fd 3 if it's available

We want two stdout streams - one for data another for metadata - instead of sending metadata to stderr - we could send it a 4th fd (3). How would we do that? Here is a bad start: my_progam > <...
2
votes
1answer
61 views

What is the most succinct way of terminating the rest of a pipeline if a command fails?

Consider the following: command1 | command2 | command3 As I understand pipelines every command is run regardless of any errors which may occur. When a command returns stderr, it is not piped to the ...
1
vote
1answer
55 views

Understanding File Streams and File Descriptors

For extra context, I asked this question earlier, and thought I understood things, but not anymore. I know that echo ignores stdin. I know that stdin, stderr and stdout exist and, in this context, I ...
1
vote
1answer
37 views

File Descriptors and Redirection

Several resources state the file descriptor 0 is connected to the keyboard. I have learned that echo does not receive input from stdin (or 0). This feels contradictory to me. When I run echo foo I'm ...
0
votes
1answer
71 views

What controls the buffering of stdout stderr?

What part of the system sets up the buffering of the three standard streams when a program is started? Is this part of linux, or glibc, or maybe bash? Does POSIX define the behaviour, or is it part ...
1
vote
1answer
62 views

writing a script that finds incorrect files, and corrects them through stdout

I am currently using UNIX bash, and I want to write shell script that allows me to correct the date entry by using information in a file's pathname. Background: I previously had 200 files that were ...
2
votes
1answer
109 views

Using diff to compare the output of two commands

How does one go about using diff to compare the output of two commands? I know how to use it to compare the contents of a file filename1 with the output of a command cmd2: cmd | diff filename - How ...
0
votes
1answer
36 views

How can I store output in bash variable and suppress output to stderr and stdout? [duplicate]

If i'm doing oidvalue=$(snmpget -v 2c -c public localhost 1234) This will store the output of that command in oidvalue, however as it is now, it will print some error to the screen. How can I ...
3
votes
2answers
347 views

Why can't I get pgrep output right to variable on bash script?

I'm trying to make a script to either quit compton if it's running or start it if it's not running. I've read from man that it should exit 1 if process is found, so I've tried to make a script that ...
1
vote
1answer
38 views

How to prevent printing to stdout from an awk **script** (not from cli)

[GNU awk v4.2.1 on Archlinux] Suppressing awk's default print action to stdout from cli is easy and well documented on UL, e.g. here. Doing so from a script gives me headaches. Here's the toy script: ...
0
votes
1answer
58 views

Confusion about stdout and stderr on the start-up terminal

I have an embedded Linux system with different programs running from start-up. Some of these programs write to stdout and stderr with printf(). When I first log into the system via SSH, I can see all ...
2
votes
1answer
40 views

Redirecting stdout and stderr from a bash script inside a bash script

I know that I can re-direct stdout and stderr from a script to a file such as follows, if this is executed directly on the command line : sh myscript1.sh &>output.txt & However if I ...
0
votes
1answer
81 views

Commands leaking characters to bash

While building a small expect script I noticed that, after executing the script, some characters were automatically on the input of bash. I have seen that on other programs before, but here I have ...
0
votes
2answers
212 views

Nohup: Redirect stderr to file and dismiss stdout

Per default, nohup writes stdout to nohup.out and dismisses stderr. I would like to have it the other way around: write stderr to a file and dismiss stdout.
0
votes
0answers
31 views

How do I know that the output is stderr? [duplicate]

When writing a very simple command in my terminal, like find ./ -name "pattern" I get a lot of 'errors' because I am not searching as sudo, and as consequence I get a lot of 'Permission denied' ...
-1
votes
1answer
61 views

Capture output of a command, process it and ONLY then output to terminal

I would like to capture the stdout (as sent to a terminal), and perform some processing after it is output on the terminal (for the user). I want to know how to grab the output, process and make ...
0
votes
2answers
25 views

Repeat command execution attempts until status is not specific, preserve data

I have a case where a first few command execution attempts after daemon restart are returning 2 (followed by stderr messages), than everything works correctly. In order to bypass this bug I've come ...
9
votes
1answer
597 views

Redirecting stdout from two programs

I'm running a memory check tool (prog1) on a C++ code (prog2), both of which give me a huge and detailed output. In order to chase down some bugs I need to save this output to a file. I tried ...
0
votes
2answers
72 views

STDOUT + STDERR output … is there any difference between considering the output to be an empty string vs NULL

I'm writing some application code that is used to execute Linux shell commands, and it then logs the command details into an SQL database. This includes the output of STDOUT + STDERR (separately). ...
0
votes
1answer
25 views

Redirecting stdout makes modem unable to connect

I'm running Yocto with busybox on an embedded system with a Telit modem. If I launch the main program, script A, with ./script_A & there's no problem at all and the modem connects on the first ...
1
vote
1answer
34 views

A command wants file paths. How can I give it stdin for the “infile” and stdout for the “outfile”?

Consider a command like foo -in /path/to/infile -out /path/to/outfile, that you'd like to pass strings to rather than using temp files. It may be called a lot causing much disk access, or is related ...
1
vote
1answer
181 views

How does sponge (from moreutils) work?

sponge can “soak up” stdin and write it atomically to a file, enabling one to do cat f|sponge a. I want to know how exactly it accomplishes this. How does it know when the input is finished?
0
votes
3answers
30 views

If-condition based on standard output

I have few commands linked through pipes, and at the end is a conditional awk: example below command1 | command 2 | awk '$1 > 800' Now sometimes it will output few lines, and sometimes no lines. ...
-5
votes
1answer
260 views

Is data streamed as stdout/stderr removed after it appears in the terminal? [closed]

I know that stdout/stderr are a streams of data (uncommonly called "sources of data"), and that these streams of data also typically appear as terminal output. After the stdout/stderr data appears in ...
13
votes
2answers
976 views

What prevents stdout/stderr from interleaving?

Say I run some processes: #!/usr/bin/env bash foo & bar & baz & wait; I run the above script like so: foobarbaz | cat as far as I can tell, when any of the processes write to stdout/...
2
votes
4answers
1k views

How to redirect stderr in a variable but keep stdout in the console [duplicate]

My goal is to call a command, get stderr in a variable, but keep stdout (and only stdout) on the screen. Yep, that's the opposite of what most people do :) For the moment, the best I have is : #!/...
2
votes
1answer
404 views

What is non-standard input/output/error

I have read books/tutorials which mention standard input/output/error. My understanding is that: standard input/output/error are concepts of a process (i.e. if someone mentions standard input/output/...
3
votes
2answers
60 views

How does `cat`'s I/O model differ from that of other utilities?

From the output of stdbuf --help (GNU): Usage: stdbuf OPTION... COMMAND Run COMMAND, with modified buffering operations for its standard streams. ... NOTE: If COMMAND adjusts the buffering of its ...
0
votes
2answers
82 views

Remove lines from stderr [duplicate]

There is custom message that comes each time I ssh or scp which I would like to hide. I still want the rest of the stderr to go to stderr output. For example: a.sh contain one line: ssh example.com "...
1
vote
2answers
287 views

Print netcat input on terminal

I'm trying to write a script where I cat the content of a file and pipe it into nc: $cat somefile.txt | nc server port The file content is sent to the server as expected but on the terminal I only ...
4
votes
2answers
468 views

How to suppress stdout / stderr from a shell script output?

I have a script that is suppose to stop and recover the process to run in the background: process_id=`ps -eaf | grep -i daemon | grep -v grep | grep -v status | grep -v stop | awk '{print $2}'` (kill ...
1
vote
1answer
196 views

python script output won't be directed to file

I have a python script. It has a SimpleLogger with sys.stdout as output_stream. logger = SimpleLogger(level=LogLevel.DEBUG) When I run it in console, I get the logs properly, but whenever I ...
4
votes
1answer
105 views

How to see from which file descriptor output is coming?

How to see from which file descriptor output is coming? $ echo hello hello $ echo hello 1>&2 hello all are going to /dev/pts/0 but there are 3 file descriptors 0,1,2
0
votes
2answers
391 views

Is there any difference between tee and >> when using echo?

Is there any difference beteween doing: echo "hahaha" >> file1 and echo "hahaha" |tee -a file1 ? Yes, I noticed that I cannot write to write protected files even aith sudo echo, but I can ...
1
vote
2answers
347 views

How to detect whether a string is present in stdout without affecting the output? [duplicate]

I have a program called my_program that prints diagnostic message to stdout I want to detect if the diagnostic messages includes string "TEST FAILURE" and if it does, execute some command after the ...
2
votes
2answers
63 views

Stderr redirection unexpectedly redirects some BASH built-ins as well

I'm trying to hide all the stderr from users running an interactive BASH script but keep the errors in a log file. However, simple stderr redirection quite unexpectedly hides some BASH output as well ...
-1
votes
1answer
2k views

Why does echo <<EOF … EOF not work [duplicate]

Just wondering if anyone can explain why this works: echo `cat <<EOF {"branch":"foo","value":"bar"} EOF` but this doesn't: echo <<EOF {"branch":"foo","value":"bar"} EOF (the second ...
3
votes
2answers
384 views

Using pipe STDOUT as a variable?

Fairly new to Bash, about a grueling week. I love it so far and really like long chaining pipes. What I'm noticing though is that I have to break the pipe if I need to use the STDOUT as a variable. ...
3
votes
2answers
87 views

What were the original reason(s) for adding a “standard error” which is separate from “standard output”?

Unix provides standard output and standard error, which can be redirected independently. $ ls /not-exist ls: cannot access '/not-exist': No such file or directory $ ls /not-exist > redirect.out ...
1
vote
1answer
57 views

Does Ctrl-C (SIGINT) prevent output to be shown even if there were processes trying to output it

I had a bash script which did the wrong thing. So I pressed Ctrl-C to stop it. Is now the output I currently see on my terminal all the output produced by the processes that have run. Are does Ctrl-...
5
votes
4answers
568 views

How do I prefix commandline output with a fixed string? [duplicate]

Suppose I run the command: sudo ./list_members Physicians And I want to prefix the output like this: Physicians user@domain.com Physicians user2@domain.com Physicians user3@domain.com Physicians ...
5
votes
2answers
161 views

Standard Out Append to File Size Limitations

I'm pulling VIN specifications from the National Highway Traffic Safety Administration API for approximately 25,000,000 VIN numbers. This is a great deal of data, and as I'm not transforming the data ...
0
votes
2answers
215 views

Why not write to stdin?

According to this answer, stdin, stdout, and stderr are all initially connected to the same place (same as /dev/tty), and the convention of reading from stdin and writing to stdout and stderr is only ...
1
vote
1answer
256 views

Print and log stdout and stderr in fish shell

I am using the fish shell and try to log stdout and stderr into two separate files and printing them in the terminal at the same time (e.g., by piping each stream to tee). In bash I would do (see ...