tee is a command line utility that reads the standard input and writes to the standard output as well as a file specified as an argument. Use this tag for questions about the tee command.

learn more… | top users | synonyms

0
votes
0answers
23 views

How to capture stderr and stdout and let them output [duplicate]

How to capture in bash - tee - both stderr and stdout and let them output to their default streams (i.e. stdout and stderr) ? Having this toy example script: $ cat e.sh #!/bin/bash echo ...
2
votes
2answers
120 views

Pipe Fail (141) when piping output into tee — why?

An example should clarify my question. This behavior makes sense to me: $ echo hi | cat hi $ echo hi | tee >(cat) hi hi The first case is obvious. In the 2nd case, we pipe "hi" into tee using ...
3
votes
3answers
105 views

Direct output to pipe and stdout

I was wondering if there is a way to pipe the output of a command and direct it to the stdout. So for example, fortune prints a fortune cookie and also copies it to the clipboard: $ fortune | tee ...
0
votes
1answer
30 views

the T-split command in linux as opposed to cat? [duplicate]

so for a question I have to store both messages of x and y to log, since y only exists and x does not I used cat x y &> log to be able to store both messages. However as the second part my ...
0
votes
0answers
18 views

Redirect stderr to stdout and tee to file and check return value [duplicate]

I know how to redirect stderr and stdout to a file: curl -sSo file http://foo.bar >> log 2>&1 I know how to get stdout to appear on the console and in a file: curl -sSo file ...
0
votes
0answers
49 views

Which iptables chain does a new stream created by TEE go to?

Where do packets go after being created by the TEE target? I am working on mirroring some traffic that needs to go to multiple computers on my network. So what happens to both streams after using ...
0
votes
2answers
74 views

bash: tee eats newlines after exec

To output both stdout and stderr from a script to the console and to a log file, I’ve found a beautiful solution with tee: exec &> >(tee log.file) The problem is, that sometimes tee seems ...
1
vote
1answer
29 views

Busybox ASH inside initrd has a problem when piping tee to sed

I'm trying to log the early boot output from the init script. This is what is working: mkdir -p /run/log && \ mkdir -p /tmp && \ mkfifo /tmp/stage-1-init.log.fifo1 && \ mkfifo ...
6
votes
1answer
428 views

Using 'ping', 'cut' and 'tee' together

So, I understand that by using 'tee' I can redirect the output of a command such as 'ping' to stdout as well as a file. For example: > ping google.com | tee somefile This would display the ping ...
5
votes
2answers
65 views

Understanding i/o redirection in the context of _process substitution_

Running GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu). I don't really understand process substitution (ProcSub) from the perspective of a user interested in lifting the hood on i/o ...
1
vote
1answer
35 views

Appending to a file suffix range with echo and tee

I am unable to figure out how to properly pipe and tee to append to a range of files. Instead of manually typing them out echo "help!" | tee >> file1 file2 file3 I am trying to figure out: ...
1
vote
0answers
19 views

How to capture “$?” before tee smashes it? [duplicate]

I've got a test script that repeatedly builds a library under different configurations. It also tee's the output for postmortem failures: $MAKE" static dynamic cryptest.exe 2>&1 | tee -a ...
2
votes
1answer
55 views

How do I let tee print all file descriptors to screen but only save stdout to file?

Suppose my program prints to multiple file descriptors and I need to watch all of the outputs as they are being printed but only save stdout to a file. How do I do that?
0
votes
3answers
230 views

ping output statistics to file

[root@localhost ~]# while true; do timeout -s 2 1h ping 96.120.16.121 | ts '%Y-%m-%d %H:%M:%S |' | tee -a ping.log; done easier to read format: #!/bin/bash while true; do timeout -s 2 1h ...
-3
votes
2answers
64 views

Can not pipe the `pwd` result to tee [closed]

I use Ubuntu 14.04. When i execute ls | tee - it works fine. But pwd | tee - just output absolute path only once and does not exit! i need to Ctrl+C to stop it. Any clue? EDIT: I use bash.
0
votes
4answers
101 views

How to log from inside the script along with stdout

I am aware that I can log using tee But I want to log from inside my script, at the same time display the content on the stdout. Example, my code looks something like this: names=$(print("name1 ...
0
votes
0answers
43 views

Preserve colours when piping to tee

I have made a little program where I update homebrew with brew update, then I send the output to a log file, but I also want to keep it on the terminal so I use tee. The problem is, it doesn't show ...
1
vote
3answers
178 views

How can I un-write protect file made by tee?

I have a small program and I want to ensure that it works on both write protected files and un-write protected files. So, instead of using echo $text > $file or echo $text >> $file, I am ...
2
votes
4answers
334 views

Extract two values from the output of a command

I'm using the following command in a script to get synthetic wifi info: echo "$( iw dev wlp1s0 link | grep '^\s*SSID:\s' | sed -r 's/^\s*SSID:\s//' ) $( iw dev wlp1s0 link | grep ...
7
votes
1answer
320 views

Does tee slow down pipelines?

I am wondering whether tee slows down pipelines. Writing data to disk is slower than piping it along, after all. Does tee wait with sending data through to the next pipe until it has been written to ...
0
votes
2answers
1k views

How to redirect output of a 'xterm -hold -e' command

I know you can use tee to log output from a command in a terminal, e.g.: df -h | tee ~/log.txt However, how can I do this with a more complex command like this: xterm -hold -e program arg1 arg2 ...
1
vote
2answers
1k views

Redirect script output to /dev/tty1 and also capture output to file

I want to display text output on the console that is always displayed on a small screen on my Raspberry Pi. The following code works for showing that text output: cd ...
21
votes
4answers
1k views

Is it possible to redirect the output of a command into more than one command?

As far as I know, I can use the tee command to split the standard output onto the screen and further files: command -option1 -option2 argument | tee file1 file2 file3 Is it possible to redirect ...
1
vote
1answer
398 views

Redirect all bash script output (from inside the script) to two files: one append, one rewrite; but discard output to the console

I can easily redirect both standard and error output of a bash script to the file, while discarding an output to console with simple exec statement: exec &>>/var/log/backup.log But how do ...
2
votes
6answers
440 views

using tee to output intermediate results to stdout instead of files

I know that to capture a pipeline's contents at an intermediate stage of processing, we use tee as ls /bin /usr/bin | sort | uniq | tee abc.txt | grep out , but what if i don't want to redirect the ...
3
votes
2answers
345 views

How to use tee to capture STDOUT from a code block to a filename defined within the block?

I want to send STDOUT for a script block to a file which name is defined by a variable within the block. However, when I use tee, it seems the variable outside the block doesn't exist anymore. Without ...
1
vote
1answer
100 views

Output Redirection

I am using the tee command to output the compilation errors of a program into a file along with the terminal. gcc hello.c | tee file.txt This is the command I have used. The compilation errors are ...
0
votes
1answer
49 views

Why doesn't this tee with process substitution produce the 1st and chosen lines? [duplicate]

What I want is printing the output the first line ( table head ) of ps aux and the grep result. After search, I come up with following. ps aux | tee >(head -1 > /dev/tty) | grep mongo But I ...
0
votes
1answer
444 views

Using tee or pipe to log console output will cause my program not to start [duplicate]

I'm running hostapd on my raspberry PI to let it function as an accesspoint. It's working fine with the following command: sudo hostapd /etc/hostapd/hostapd.conf This will start hostapd and log all ...
0
votes
1answer
146 views

Keep PHP's output with tee -a

Normally when running PHP script in web server mode, this would show up: $ php -S 0.0.0.0:12345 PHP 5.6.1 Development Server started at Mon Nov 24 14:09:22 2014 Listening on http://0.0.0.0:12345 ...
0
votes
3answers
162 views

How to save in a variable the convert from decimal to binary without use an echo

I've been trying to save in a variable the value of the convert of a number from decimal to binary, like this: num1=10 echo "obase=2;$num1" | bc | tee -a register.txt but I don't want to show it ...
1
vote
1answer
258 views

Redirect output to stdout and pipe to a binary

I have a nice PS1 line in my .bash_profile, and I want to copy it to another machine. So I want to view it AND copy it to my clipboard. I can't figure out how to string the commands to do this ...
1
vote
2answers
579 views

Append a file, output to screen and redirect from stderr all at once, without tee

I'm running a time dd command in a shell script, and I'd like to output the results to a file, and print it out on the screen. The line that I'm currently running is: (time dd of=$dest_filepath ...
2
votes
2answers
162 views

How to write to a file with netcat? And set it to grow to a certain size and begin overwriting itself?

I'm currently writing a program that prints to a Zebra printer. Because my office doesn't have a zebra printer, we print to a linux VM running netcat with nc -k -l -p 9100 | tee labels.txt so that we ...
1
vote
0answers
136 views

Verbose output in logfile and simple output on screen?

Let's say I have the following script: script.sh and i want the verbose output in a logfile and simple output on screen. Logfile should contain the csh -v script.sh output, and on the screen should ...
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
11k views

Using exec and tee to redirect logs to stdout and a log file in the same time [duplicate]

In a bash script, how can I redirect all standard outputs to a log file and tee the output on the screen using exec ? log_file="$HOME/logs/install.txt-`date +'%Y-%m-%d_%H-%M-%S'`" [ -f "$log_file" ] ...
8
votes
2answers
660 views

Redirecting output depending on grep regex

I am using gradle run to start a REST server. The output of the REST server looks like this: XXX.XXX.XX.XXX - <moreinfo> randomtext randomtext XXX.XXX.XX.XXX - <moreinfo> XXX.XXX.XX.XXX - ...
2
votes
1answer
569 views

bottomless tee?

I was just playing around in the terminal and I did this: printf 'some string\n' | { tee /dev/fd/3 | { : && sed 's/some/string/' } } 3>&0 I was really surprised when ...
2
votes
2answers
719 views

Process substitution with tee and paste

I'm trying to pipe a command through the output of two other commands and then merge the results of the two process substitutions. An example that gets me close is: command | tee >(sed -rn ...
1
vote
2answers
313 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, ...
4
votes
2answers
177 views

Running several times the same command with several arguments after a pipe

I have a key (of random binary data) that gets generated by get_key. And with this key, I can do several things with my encrypted files. For example, I can decrypt them. get_key | tee >(decrypt ...
1
vote
0answers
34 views

Filter partial output of some script [duplicate]

I need to analyze the output of some script So, I know their header and their tail of some part of the output script, but not the content. I found an approach [1] But I need something like: $ ...
15
votes
3answers
2k 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 ...
3
votes
2answers
223 views

tee / sudo password cache conflict?

I have a large bash script (Ubuntu 12.04). The script is designed to be invoked by a regular user; only certain commands within the script run with sudo. It is not an option to run the entire script ...
3
votes
4answers
271 views

saving output of another command

I need to select certain lines from the log file and also save them to a text file. I tried the following but none of them are working as expected. The file "todel.txt" shows 0 bytes. tail -f ...
4
votes
1answer
596 views

Logging interactive input and output without capturing all typed input and control characters

I am trying to log output from an interactive command-line program; units, specifically. I have tried using tee like this: units | tee units.log or script like this: script -c units units.log ...
4
votes
3answers
5k views

How to get mplayer to play from stdin?

Why doesn't this work? cat /dev/video1 | mplayer - If I could get that to work, then I could play & record video at the same time using 'tee' to feed mplayer and mencoder. I want to play live ...
0
votes
2answers
116 views

Why does this command work for logging script output?

This command does not store the output of my script in the log file: . myscript.sh | tee -a log_file.log However this next command does store the output in the log file. . myscript.sh 2>&1 ...
5
votes
2answers
609 views

Reusing pipe data for different commands

I would like to use the same pipe for different applications, like in: cat my_file | { cmd1 cmd2 cmd3 } Cmd1 should consume part of the input. Cmd2 should consume another part and so on. ...