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 ...

learn more… | top users | synonyms

0
votes
0answers
16 views

Using tee to get realtime print statements from python [migrated]

I have a python script that looks something like this: for item in collection: print "what up" #do complicated stuff that takes a long time. In bash, I run this script by doing the ...
0
votes
0answers
54 views

Text replace literally *all* instances of a string through stdin, stdout

Linux, or specifically Ubuntu 14.04 LTS Server if necessary (and CENTOS 6.5/7 minimal would be nice). If I enter "FOO" at the command line, (regardless of whether as a word or as a substring), I'd ...
2
votes
2answers
40 views

Output piped content to file and show number of lines in the file on stdout

I would like to use tee to pipe content from stdout and stderr respectively into files (in fact append it with > >(tee -a $filename)). However, instead of seeing the contents appended to the ...
4
votes
6answers
493 views

Command to output file content to stdout?

I know cat can do this, but its main purpose is to concatenate rather than just displaying the content. I also know about less and more, but I'm looking for something simple (not a pager) that just ...
13
votes
2answers
804 views

How to find out what process is writing to STDOUT?

I have two instances of a process running. One of them is "frEAkIng oUT!" and printing errors non stop to STDOUT. I want to kill the broken process but I have to make sure I don't terminate the wrong ...
1
vote
5answers
107 views

How to overwrite stdout using echo? [closed]

We know to overwrite bar.txt, we can use this: echo "foo" > bar.txt but how can we overwrite to the standard output? I tried this command: echo "foo" > but it failed. I want this because ...
4
votes
1answer
72 views

unexpected output with grep

I am using pyrit. For those who dont know, pyrit allows among other things to check if a wpa handshake key is valid: pyrit -r file0.cap analyze when a file does not contain a valid key, here is ...
4
votes
4answers
284 views

A command that generates both standard error and output

I want to do some troubleshooting on my bash script. Is there a short and simple command that generates both stdout and stderr so that I can use 2>&1 on it? Sorry if this looks trivial, but I ...
1
vote
2answers
51 views

Call background process back to stdout

Is it possible to "call" a background process output to be shown in the terminal? Example: cron starts apt-get to update the system and I want to see the output of apt-get
7
votes
5answers
2k views

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 ...
5
votes
1answer
104 views

Rotating log files while process still running

I have a process running that writes standard output and standard error to a log file /var/log/dragonturtle.log. Is there anyway to rotate the log file, and have the process continuing to write to the ...
2
votes
4answers
86 views

Command line 'buffer' [duplicate]

I wanted to tail the last 100 lines of a file to the same file, but the command tail -n 100 file > file doesn't work, I assume because the stdout gets written to the file 'live', before everything ...
1
vote
0answers
16 views

Test execution output of a command before a pipe [duplicate]

I would like to test the execution of a php script that redirect its stdout and stderr to a file with tee. php /path/to/script --param 2>&1 | tee -a /path/to/log if ( test $? -ne 0 ); then ...
5
votes
2answers
89 views

How can I pipe stdout to another program?

I'm trying to setup a linter for my code and I only want to lint the coffeescript files that have changed in the current branch. So, I generate the list of files using git: git diff --name-only ...
3
votes
2answers
77 views

Decoding “prog > file 2>&1”

I am having some difficulty understanding the construct prog > file 2>&1. I have read that it means "Send stdout and stderr to file". But my question is how? I understand that prog > ...
4
votes
2answers
112 views

How to redirect stdout to a file and read from the same file simultaneously with another task?

I want to run a task (which takes quite a long time) remotely in Ubuntu Linux Bash via nohup and redirect stdout to a file, e.g.: nohup task > out.txt & From time to time I would like to ...
23
votes
4answers
4k views

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: ...
9
votes
2answers
258 views

How a piped shell programs balance their output/input rates? [duplicate]

Possible Duplicate: Bash while loop and reading from pipe I come from web programming background, and find myself interested in one peculiarity of using a local shell. I understand that ...
1
vote
3answers
131 views

Inserting the command line text before output in stdout (for pipe / redirection)

Consider the following bash constructs: ls /usr/include/asm > list-redir.txt ls /usr/include/asm | tee list-tee.txt In this case, list-redir.txt and list-tee.txt will be identical, and will ...
2
votes
1answer
48 views

stdout is empty

When a run the command: cellprofiler --get-batch-commands "/users/pmrotem/CellProfiler/example_project/output/Batch_data5_8.h5" in the shell, I get an output: CellProfiler -c -r -b -p ...
1
vote
2answers
63 views

grep a keyword from Mplayer output and send the rest to file

I am using mplayer. I want to send everything to a log file (/tmp/server.log), but I want the Volume output to be written to the terminal. I have seen that there is a way to split the output with tee, ...
2
votes
3answers
103 views

Script needs to read echoed line

So, I need to write a Bourne-shell script, where my script has to work with the line, that was just echoed to stdout - e.g.: echo *something* | myscript.sh [parametres...] This may be a basic ...
9
votes
3answers
761 views

tee stdout to stderr?

I'd like to send stdout from one process to the stdin of another process, but also to the console. Sending stdout to stdout+stderr, for instance. For example, I've got git edit aliased to the ...
4
votes
1answer
176 views

Piping commands, modify stdin write to stdout

echo Hello World | nano - | less I want to modify Hello -> Goodbye while in the the text editor. It does not have to be with nano. I am stuck with nano reading stdin but requiring me to write to a ...
4
votes
4answers
189 views

How do I break up a file like split to stdout for piping to a command?

I have a large .sql file full of SELECT statements that contain data I want to insert into my SQL Server database. I'm looking for how I could basically take the file's contents, 100 lines at a time, ...
2
votes
3answers
102 views

Is it possible to generate a separate file list when creating a tarball?

When using tar for backups I'd like to create a separate list of the files that is included in the archive for storing alongside the backup tarball. I also want to be able to store the error messages ...
4
votes
3answers
574 views

Dynamically trim stdout line width in Bash

Lately, I have been experimenting with the ps command, and sometimes long paths wrap to the next line (or two) and make it hard to read. I want to pipe the ps output into another program to limit the ...
2
votes
1answer
1k views

Linux : how to redirect stdout & stderr to logger?

I have a program I need to run at startup, it has output on stdout and stderr that I want to redirect to the system log using the logger command. What I have in my startup script is thie: ...
2
votes
3answers
156 views

How do I make pasted shell commands invisible?

I'm using an AutoHotkey macro to run some shell commands, i.e. ^`:: SendInput set c=".cshrc-acheong"{ENTER} SendInput set v=".vimrc-acheong"{ENTER} SendInput foreach d ( /home/acheong /home/tcama ...
2
votes
4answers
105 views

Can a running script identify the logging context?

Let us say I redirect the STDOUT, STDERR of a program to files. ./script.sh 1> output.log 2> error.log Can the running program find this out i.e. know the paths to these files?
1
vote
2answers
2k views

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 ...
4
votes
4answers
367 views

Reuse last line of output from shell command

I am compiling something and depending on success (last line of output contains "success"= I want to scp the binary to the target. I'd prefer a piped oneliner. Is there a way to do this?
7
votes
2answers
293 views

Kill a process if it goes quiet for a certain amount of time

I have a utility that has a nasty habit of going quiet and staying there, I already know how long into the process it does this so I am using timeout to fight this, but sometimes it does it before ...
28
votes
4answers
8k views

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, ...
5
votes
2answers
244 views

Write lines to a file from less

While in vim I can write a range of lines from the file I'm viewing to another file. For example, :1,10 w outfile.txt will write lines 1 through 10 to outfile.txt. Can I do the same while I'm ...
-5
votes
2answers
89 views

What is the utility of piping to `/dev/null`?

Seeing that /dev/null's utility isn't immediately obvious to me, what is the use of /dev/null piping?
4
votes
1answer
128 views

Can redirecting stdout and stderr to the same file mangle lines?

I've read that when redirecting stdout and stderr to the same file using 2>&1, stdout is usually block buffered while stderr is unbuffered. If a very long line is written to stdout, requiring ...
2
votes
2answers
118 views

Show a sliding window of output from a program

I want to run a command (rsync -av) and only display 10 lines of output at any time. I have found a similar post, but I don't want to redirect it to a file. I want the output to be displayed ...
3
votes
1answer
75 views

What is the relationship between a program's output, standard output, and its file descriptors?

Let's assume that I am running wget which is downloading something. It's printing some text to my terminal and writes the downloaded data into a file. From a terminology point of view, what is the ...
3
votes
2answers
216 views

Bash if script is called from terminal echo stdout to terminal, if from cron do not echo output

I would like to have a service watchdog script echo the status to the screen if called like ./watchdog.sh but if it is run by cron, there is no need to echo output. What is the proper method? Where ...
1
vote
2answers
3k views

How can I get vsftpd version into shell variable?

I want to get vsftpd version into shell variable. I can get it to console with ease: # vsftpd -version vsftpd: version 2.2.2 Also I can get a lot of other info into variable: # i=`bash --version ...
4
votes
4answers
197 views

Any way to cat few lines of man page to show on stdout for reference?

This is a simple question. Trying my best to put it in simple word. Hope you get it without much confusion - I read a man page for some command-switch/option which has a long description. I read it, ...
5
votes
1answer
383 views

`unbuffer` or `stdbuf` for removing stdout buffering?

Is there a difference between unbuffer(1) and stdbuf(1)? From what I gather, unbuffer makes more than the "best effort" of calling the libc function set(X)buf at the beginning, and then letting things ...
2
votes
3answers
116 views

How can a command have more than one output?

In this answer, at the very bottom, Gilles mentions that a command can have more than one output or input. Yes, there's cat foo bar | something, for having both foo and bar as inputs, and there's tee ...
3
votes
5answers
1k views

How to use filename arguments or default to stdin, stdout (brief)

I want to handle filenames as arguments in a bash script in a cleaner, more flexible way, taking 0, 1, or 2 arguments for input and output filenames. when args = 0, read from stdin, write to stdout ...
1
vote
1answer
109 views

Pipe not picking up stdout

I am running a java program from a OS X 10.8 bash terminal, and are trying to rederect the output it is producing. However, when either running this throug a pipe, or rederecting it to a file, the ...
2
votes
1answer
41 views

aptitude produces output twice

For quite a while, I get a double output of some messages from aptitude. Here’s an example: > sudo aptitude install mpw Couldn't find package "mpw". However, the following packages contain "mpw" ...
10
votes
2answers
1k views

Script to quickly test all keyboard keys

I need to check some notebooks for bad keyboard keys, and so I'd like to speed that up as much as possible. I found nothing for this specific task, so my idea is a script that reads the pressed keys ...
5
votes
3answers
5k views

bash: /dev/stderr: Permission denied

After upgrading to a new release version, my bash scripts start spitting errors: bash: /dev/stderr: Permission denied in previous versions Bash would internally recognize those file names (which is ...
5
votes
1answer
74 views

Is it possible to create sticky redirection from stdout/stderr

Consider such code: echo hello >> log.txt echo world >> log.txt I execute command with stdout redirection. Is it possible to create sticky redirection? Something like this: redir ...