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.

Filter by
Sorted by
Tagged with
0
votes
2answers
51 views

Is it possible not to override a file in case of error when redirecting STDOUT?

I have a simple syntactically wrong command like this that is meant to be run on Unix/Linux hosts $ echo "first string $PATH" > out.lst $ ECHO second string %PATH% > out.lst The first line ...
0
votes
0answers
14 views

Print clang include path and store in file

I'm writing a program that needs to pull in the clang include paths. Thanks to Dump include paths from g++ I'm half-way there. The command I'm using is: clang++ -E -x c++ - -v < /dev/null The ...
0
votes
1answer
46 views

Use 2>&1 to direct stdout/stderr for a single command only among many in a BASH script

My first post, please be kind :) I'm writing my first ever BASH script, and using systemd to invoke it on a timer (my first systemd units too!). The script runs backups daily, and uses notify-send to ...
0
votes
0answers
52 views

How does history print to the terminal?

EDIT: As per @JdeBP's comment, I've learned that the history command and the history recall functionality of interactive terminals are two separate things. I am, however, still curious about how the ...
1
vote
1answer
20 views

Persist file redirection between exec calls

Is there a way to persist file redirection commands between exec calls? For example, there are two bash scripts. In script 1, I am setting up redirection of stdout and stderr to file. Then exec-ing ...
1
vote
1answer
36 views

How do I attach myself to a process running in an inacessible terminal?

I have a process running in a terminal I'm unable to access due to that the X session it is running in is frozen. I would like to send some commands via stdin that tell it to stop before I kill the X ...
0
votes
0answers
12 views

Python script output from docker container that is bash'd into does not 'overwrite' output lines?

I have an nvidia-docker container running, I have bash'd into it with sudo docker exec -it container_name bash and starting running a Python script which trains a model with Keras python main.py ...
0
votes
0answers
41 views

`echo` in bashrc ignored over ssh

If I add a line like echo 'Hello' in my ~/.bashrc, it works, but when I ssh into the machine it simply ignores all echo commands. In fact, I think it ignores all of stdout. If I add a line like echo '...
0
votes
1answer
35 views

command stdout to /dev/null

I have very simple command which generating STDOUT which i want to do /dev/null but somehow it's not working or i am missing something here. $ ldapsearch -Y GSSAPI -b "cn=users,cn=accounts,dc=...
1
vote
0answers
49 views

How does redirecting stdout to stderr work [duplicate]

Just trying to redirect stout to stderr. But I'm a little confused about these two commands. echo test 2>/dev/null 1>&2 echo test 1>&2 2>/dev/null I don't understand why the ...
-1
votes
2answers
92 views

Best way to `tee` to stdout and to a process

I want to do something like this: echo 'foo' | tee /dev/stdout > >(cat) where the stdout from echo gets sent to the terminal and to the cat process. Is there a simpler way to do this? When I ...
2
votes
0answers
135 views

How to show rsync progress when running as systemd service

I have a bash script sync_nodes.sh that I want to manage with a systemd unit sync_nodes.service. I want the progress of of the rsync command to show up in my logs. When I run the command ...
0
votes
0answers
61 views

Non blocking cat (Read as much data as you can from stdin and hold it in RAM until a write-blocking stdout becomes available)

I have a program (which may or may not be aplay) that accepts its stdin rather slowly. Programs that write to said stdin (such as via a pipe) tend to block on writes a lot. Needing to wait on input ...
0
votes
0answers
37 views

Grep a STDOUT of an ssh command

I have synced a Jupyter Notebook to a Spark EMR Master Node. Have written a script to automatically start it over ssh in a separate venv and forward the notebook http port. This works fine, but i need ...
0
votes
0answers
23 views

Why I get the output of stderr printed in terminal instead of a file when I redirect the stdout into stderr? [duplicate]

When I run a command with output redirection into stdin like that: sudo -u postgres psql mydb -e -f ./my_psql.sql 2>&1 > output_log.log The error messages are being displayed into the ...
-3
votes
1answer
112 views

Time and again I forget the meaning of a single hyphen in the end of some utility commands [duplicate]

Time and again I come across old codes and recognize a single hyphen in the command's end: mysqldump -u root -p --all-databases | zip "$drt/db-$date.zip" - or wget ${target_url} -O - | tar -xzv --...
7
votes
3answers
436 views

Find a text string in a file and output only the rest of the text that follows it?

I am finding a lot of posts on this forum that have to do with finding various values in a text file and outputting text surrounding it. However, I don't seem to find any "stream oriented". I want ...
1
vote
2answers
147 views

tar contents in current directory to stdout

I am trying to tar the current directory and stream to stdout (ultimately to Amazon S3)...I have this command: tar -cf - . but I get this error: tar: Refusing to write archive contents to ...
0
votes
2answers
345 views

Getting only last line of continuous stdout

I'm using sar to collect network statistics from my wlp2s0 interface (1 second interval), like so: $ sar -n DEV 1 | grep wlp2s0 and the continuous output looks like this: 18:15:06 wlp2s0 ...
0
votes
1answer
89 views

Suppress standard Output

Here is my command in the shell script. I want all the output to be redirected to a standard Log File. It does that fine except at when it does not find the *.txt files with a directory or sub ...
0
votes
2answers
119 views

Can I pipe stdout to the middle of a command with emacs?

The command emacs -nw foo -f org-mode opens the file foo in emacs in org-mode. Now, suppose that the filename foo is the output of a script. How could I pipe to my command? So, I'm trying to get ...
1
vote
1answer
165 views

stdout is accessible to user but not from su - user

I'm testing redirecting programs std_out to /dev/stdout in docker alpine. I can't figure out why I can echo from user to stdout, but not from su command. docker exec -it 779ddea6ec33 bash # root ...
0
votes
0answers
44 views

Script - Write stdout and stderr to a file AND to the terminal without pipe [duplicate]

I don't know if it's possible, I would like start a bash script without pipe which write everything to a file and at the same time see the output on the terminal. So I know how to do that with this ...
0
votes
3answers
56 views

What is the best way to direct stdout & stderr to multiple logfiles?

I have a purge process that I am running and the command I'm using is : find $sentPurgerFolder -mtime +7 -print -delete >> $sentPurgeLogFile 2>&1 This code is in a while loop that is ...
1
vote
2answers
56 views

Tomcat startup script output not available with piping (grep)

I'm completely puzzled by this behavior of Tomcat 9.0.21 startup script catalina.sh: # following line added by me echo "CATALINA_HOME" # following line added by me echo $have_tty if [ $have_tty -eq ...
-1
votes
1answer
47 views

When using the snmpstatus command, redirect any terminal output including 'Timeout: …' to a variable

I am running bash 5.0.007-1 and net-snmp 5.8-2 on an up to date arch linux. This line collects the status of a device: snmpstatus -c public -v1 192.168.1.240 When the device is not powered on, ie ...
2
votes
2answers
134 views

Openssh client is blocking forever if stderr is redirected to stdout

It seems there might be a problem in the openssh. In the bash shell if I redirect stderr to stdout it's blocking forever, so I have to KeyboardInterrupt: $ ssh -fTNF './config' -MS './sockd5/...
27
votes
3answers
2k 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
105 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
99 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 ...
33
votes
5answers
4k 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
683 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
255 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
67 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
104 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
214 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
96 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 ...
1
vote
1answer
774 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
101 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
2answers
337 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
286 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 ...
4
votes
2answers
1k 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
257 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
191 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
289 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
180 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
970 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
35 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
400 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
29 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 ...