Questions tagged [tee]
47 questions
150
votes
6 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
- 3,078
107
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,122
62
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,502
- 4
- 18
- 20
12
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
- 221
11
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
- 213
10
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
- 201
9
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
- 191
9
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
- 873
5
votes
1 answer
How to print and pipe log file at the same time?
I use this to check the log lines of a log file until the occurrence of a specific event (taken from this answer to Monitoring a file until a string is found):
(tail -f -n 0 test.log &) | grep -q 'SPEFICIC LOG MESSAGE'
This works, but I also want…
not2savvy
- 608
5
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,205
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
- 63,170
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.
- 17,755
4
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
- 2,143
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,517
- 3
- 25
- 27
3
votes
1 answer
Pipe output of command line by line in Windows
I'm running a server from a batch file and I want the server output to be displayed both on the screen and also written to a log file. I found a way to do this from this answer:
powershell "startmyserver | tee server.log"
The problem is that the…
Kidburla
- 573