Questions tagged [tee]

In computing, tee is a command in various command-line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which displays or pipes the output of a command and copies it into a file or a variable. It is primarily used in conjunction with pipes and filters.

In computing, tee is a command in various command-line interpreters (shells) such as Unix shells, 4DOS/4NT and Windows PowerShell, which displays or pipes the output of a command and copies it into a file or a variable. It is primarily used in conjunction with pipes and filters.

enter image description here

tee is normally used to split the output of a program so that it can be seen on the display and also be saved in a file. The command can also be used to capture intermediate output before the data is altered by another command or program. The tee command reads standard input, then writes its content to standard output and simultaneously copies it into the specified file(s) or variables. The syntax differs depending on the command's implementation.

Examples on wikipedia.

19 questions
9
votes
3 answers

tee and assigning to variable?

I need to see output on the screen and at the same time grep the output and send grep result to variable. I think it can be done with tee but I can't figure out how exactly. I tried mycommand | tee myvar=$(grep -c keyword) mycommand | tee …
Putnik
  • 2,095
  • 3
  • 23
  • 40
7
votes
1 answer

screen causes "tail -F | grep" to echo unmatched lines

This is Ubuntu (3.13.0-29-generic #53), trying to do a simple bash script to monitor a log file for matching lines. If I do the following, there is no output in the bash shell except for matches, which is expected: tail -F server.log | grep…
Dale Mahalko
  • 725
  • 1
  • 6
  • 16
6
votes
2 answers

Why is this tee losing stdout?

Simple script: #!/bin/bash remote_ssh_account="depesz@localhost" directory_to_tar=pgdata exec nice tar cf - "$directory_to_tar" | \ tee >( md5sum - | \ ssh "$remote_ssh_account" 'cat - > /tmp/h3po4-MD5-2012-03-13.tar' ) | \ …
user13185
4
votes
1 answer

iptables + TEE doesn't work correctly

On my server, I want to duplicate all the traffic to an other host. I use iptables with TEE module: iptables -t mangle -A PREROUTING -i eth0 -j TEE --gateway IP_SERVER2 I check the rule: iptables -t mangle -L => The rule is here but it doesn't…
user155731
  • 43
  • 3
3
votes
2 answers

Execute command over SSH while logging live output

I'm trying to log the output of a remote ssh command. I'm current using ssh USER@IP | tee -a ~/random.log and then run the command I need to run on the remote server which then logs to random.log. I need this to be able to run in the background,…
Stephen
  • 33
  • 1
  • 3
2
votes
1 answer

Tee command is reducing the lines?

I have the code like this : 54 08 * * * /usr/local/bin/curator --dry-run --config /home/itadmin/.curator/curator.yml /home/itadmin/.curator/daily.yml 2>&1 | /usr/bin/tee -a /home/itadmin/.curator/logs.txt | /usr/bin/tee…
Private
  • 277
  • 1
  • 2
  • 9
2
votes
1 answer

UDP Proxy with cloned packets

Having UDP messages sent from dynamic public IP periodically to public IP X:20000. Need a proxy that listens in IP X:20000, then forwards duplicate/clone packets to X:20001 and a different machine located in IP Y:20000. Now, when application…
jacktrades
  • 612
  • 3
  • 8
  • 15
1
vote
1 answer

Debugging rsync over SSH in verbose mode using tee to redirect stdout to log file

I have been having issues with various rsync operations over SSH, on a particular machine on our network, failing and giving errors like: rsync: connection unexpectedly closed (45482 bytes received so far) [generator] I found a similar post (rsync…
PicoutputCls
  • 243
  • 4
  • 15
1
vote
1 answer

How do I pipe stdout and std error to a file and back to stdout on Windows?

On Windows when running a batch script I want to record the output of I run: myprogram.bat 1> mylog.log 2>&1 Which is great - but I have to run a separate tail process to read the output in another window. What I want is to be able to record it to…
Hawkeye
  • 2,669
  • 9
  • 30
  • 34
1
vote
1 answer

Bash: Output of a command is written only to screen and not to another file while using tee, what could be the reason?

In order to troubleshoot some ftp connection error, I've been instructed to write a bash script which will infinitely connect to a remote frp server and get one file from there. ftpuser="ftpuser" ftppasswd="ftppasswd" ftpsrv="download.akamai.com"…
Itai Ganot
  • 10,424
  • 27
  • 88
  • 143
0
votes
1 answer

How can I gathering Network Traffic on AWS?

I am building packet mirroring using the Linux type's iptables tee module. In the case of instances(EC2), we confirmed that promiscuous mode can be set on AWS console configuration. than, I wonder if it's possible to use promiscuous mode on…
scott
  • 9
  • 2
0
votes
1 answer

logger and tee running in background?

Sometimes I notice the server is running slowly and at those times a ps -e shows that logger and tee are running but I can't think of why. Is this a known issue? Why would these need to run without being called? When this happens there are very…
stone.212
  • 247
  • 2
  • 11
0
votes
1 answer

Trying to send output to log file with tee using systemd but the log file isn't being created?

I want to run a node application via systemd and have its output go to both stdout and a log file. The node app is in the folder named www/www.appname.com and I want to have the log file in www/log.appname.com. I have the following service…
sigil
  • 103
  • 2
0
votes
1 answer

Can't empty log files

The servers at my work have a script made by me that every midnight copies log files to a folder, copies this folder to Amazon S3 and zeroes the original files. However, I saw that the original files haven't been zeroed and this is affecting disk…
JM Calil
  • 1
  • 3
0
votes
2 answers

rewrite destination IP of TEEed traffic

Server 1 and Server 2 (Centos 7) both host the same application, which listens on UDP port 1514. Server 1 receives traffic on this port. The goal is for the application on Server 2 to receive a copy of this traffic. Server 1 uses iptables to…
1
2