Questions tagged [tee]
42 questions
102
votes
10 answers
What is the purpose of 'tee'?
All the usages of tee I ever saw were such:
do_something | tee -a logfile
Or:
do_something_else | tee logfile
Is tee invented for those that don't know you can do the same with shell pipe redirections? Such as:
do_something >>…
R Moog
- 1,073
- 2
- 5
- 4
97
votes
4 answers
Preserve colors while piping to tee
ls -l --color=auto | tee output.log
Without pipe/tee it's colored. How can I make it so that it stays colored while using tee (can be colored only on the screen, I don't care about colors in logs).
Paweł Gościcki
- 2,418
- 2
- 22
- 26
49
votes
9 answers
Alternative to the tee command without STDOUT
I'm using | sudo tee FILENAME to be able to write or append to a file for which superuser permissions are required quite often.
Although I understand why it is helpful in some situation, that tee also sends its input to STDOUT again, I never ever…
aef
- 1,282
- 3
- 17
- 20
10
votes
2 answers
tee: What exactly does "--ignore-interrupts" option do?
The title basically says it all. tee has an option --ignore-interrupts:
-i, --ignore-interrupts ignore interrupt signals
Can anyone explain/give an example in which situation this is important? Thanks!
alexander.biskop
- 203
- 2
- 6
10
votes
1 answer
PowerShell and Tee
I use this command to see output both in the console and a file:
powershell -command "my_command_1 | tee ('logs\{0}.log' -f (Get-Date -format 'yyyy.MM.dd-HH.mm'))"
powershell -command "my_command_2 | tee ('logs\{0}.log' -f (Get-Date -format…
race1
- 201
- 2
- 4
7
votes
3 answers
Use netcat as a proxy to log traffic
I want to use netcat as a proxy to log http requests and responses to files, then tail these to inspect traffic. Think wireshark.
Tried the following where 'fifo' is a named pipe, 'in' and 'out' are files, netcat proxy on port 8080, server on port…
deephacks
- 171
- 1
- 1
- 2
6
votes
1 answer
Tee a script to file within itself
I'm familiar with using tee, and I know that I can simply log output with
script.sh | tee file.log
However, I want a seamless interface for the user. Is there a way to, within script.sh, run tee as if it was being done as above? Within this script…
Brydon Gibson
- 681
- 1
- 7
- 17
4
votes
6 answers
How can I both pipe and display output in Windows' command line?
I have a process I need to run within a batch file. This process produces some output. I need to both display this output to the screen and send (pipe) it to another program.
The bash method uses tee:
echo 'ee' | tee /dev/tty | foo
Is there an…
Bob
- 58,040
- 23
- 182
- 208
4
votes
1 answer
How to tee to stderr? (multiple sinks in one pipeline)
some_source | (tee /dev/stderr | sink_1) 2>&1 | sink_2
Seems to fail.
How to do it right without of any temporaries?
Vi.
- 15,745
- 28
- 103
- 182
4
votes
2 answers
Can you prefix each line written with tee with the current date and time?
I am using the 'tee' command in order to capture the results of a long bash command to a file.
Can the file I emit with tee somehow prefix each line with the timestamp of when the line was written? I'm looking for a solution in which each line would…
user2917346
- 41
- 1
- 2
4
votes
1 answer
Can I calculate the checksum of a file as I create it?
I am creating a large tar archive and I would like to create the checksum of the archive too. I could achieve it like this:
$ tar cfz archive.tar.gz files
$ sha256sum archive.tar.gz > archive.tar.gz.sha256sum
But the archive file is huge and on…
jl6
- 1,125
- 4
- 15
- 27
3
votes
1 answer
Linux: redirecting stdout and stderr
I want to write stdout to a file but also prints stdout and stderr. I tried using tee:
prog | tee stdout.txt
but this causes the printed stderr and stdout to be interleaved incorrectly, i.e. if the correct output should be
OUT1 ERR1
OUT2 ERR2
OUT3…
Lie Ryan
- 4,241
- 3
- 21
- 26
3
votes
2 answers
Let Tee Handle Carriage-Returns Better
I've written a Java-console application that repeatedly prints its status to the console using carriage-returns (\r) at the end rather than line-feeds (\n) to keep the output on one screen. I also want to pipe that output to a file, like
java -jar…
sjngm
- 1,953
- 3
- 20
- 29
2
votes
2 answers
tee causing bash scripts to hang
I have a script that calls a number of other install scripts
./script1.sh 2>&1 | tee script1.log
./script2.sh 2>&1 | tee script2.log
./script3.sh 2>&1 | tee script3.log
They all look ok till the last one which does a call to a custom…
./script2.sh 2>&1 | tee script2.log
./script3.sh 2>&1 | tee script3.log
They all look ok till the last one which does a call to a custom…
Terry
- 51
- 1
- 4
2
votes
1 answer
cygwin mirrors/ repositories - tee and svn
I have run Cygwin setup using a handful of different repositories, but certain programs appear to be missing from from the ones I have tried so far. I am specifically looking for tee and svn.
Which repositories/ mirrors are complete?
bguiz
- 1,891
- 5
- 21
- 33