Questions tagged [tee]
46 questions
121
votes
5 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,728
- 3
- 23
- 26
105
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,103
- 2
- 7
- 4
58
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,442
- 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
- 2
- 4
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
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
- 1
- 1
- 2
8
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
- 763
- 2
- 7
- 18
6
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
- 161
- 1
- 2
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
- 521
- 1
- 4
- 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
- 60,938
- 25
- 191
- 216
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.
- 16,755
- 32
- 111
- 189
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,165
- 4
- 16
- 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,507
- 3
- 22
- 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
- 2,101
- 3
- 21
- 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