Questions tagged [tee]

For questions related to Linux syscall and a user program that duplicates the contents of a pipe. For security frameworks, use the tags [trusted-execution-environment] or [op-tee].

Introduction

The tee command reads from standard input and writes to standard output and files.

Examples of writing standard output include:

# print output of ps to a file
$ ps aux | tee ps_aux.txt

Using tee with sudo command

$ echo 'foo' >> file 
zsh: permission denied: file

As part of a pipe, tee can take the input and elevate permissions

$ echo "foo" | sudo tee -a file 

Links

How do I “tee” variable number of times in a bash “for loop”?

Linux and Unix tee command

536 questions
0
votes
1 answer

Perl: Tee both merged STDOUT + STDERR and STDERR to separate files without CPAN modules

I have searched the internet for different solutions and the closest I have done is an exercise in open statements: use strict; use warnings; use Carp; # Save previous state my ($old_out, $old_err); open($old_out, ">&", \*STDOUT) or …
crlb
  • 1,282
  • 12
  • 18
0
votes
2 answers

Tee Command to save output in txt file

I want to copy the output in cmd prompt to txt file. I used the following command: sample.exe /all > sample.txt But the above command shows only the printf statements not showing the scanf. So i moved to tee command. Can anyone provide me the…
Balaji Kondalrayal
  • 1,743
  • 3
  • 19
  • 38
0
votes
2 answers

write to file with tee command in python

I have a python script with variable names e.g V and It. I make a filename based on the parameter as following: file_out=io.open("file_Iter" + str(It) + "_V_" +str(V)+".txt", 'w') Then I'd like to redirect all my terminal output to a this file, so…
physiker
  • 889
  • 3
  • 16
  • 30
0
votes
2 answers

Perl STDERR printed in the wrong order with Tee

I'm trying to redirect STDOUT and STDERR from a perl script - executed from a bash script - to both screen and log file. perlscript.pl #!/usr/bin/perl print "This is a standard output"; print "This is a second standard output"; print STDERR "This…
Arka
  • 307
  • 1
  • 6
  • 17
0
votes
1 answer

How to duplicate stdin into file

I have sophisticated bash script that uses "read -p"(stderr output) very often. And now I need to duplicate all script input from terminal into log file. tee file.log | script.sh this command does'nt work carefully because ignores output to…
Andrey Burykin
  • 700
  • 11
  • 23
0
votes
1 answer

C# PowerShell running non PowerShell scripts

I am trying to run a tcl script in a powershell so that I can take advantage of some of the powershell features, namely, the tee feature to display the script output in the console and record it to a file in realtime in Windows. The issue is that I…
radensb
  • 664
  • 1
  • 7
  • 25
0
votes
1 answer

When tee command redirect to subshell, the last two lines missing

I have below solution to record a command and its output executed on a remote machine: rexec:// -t -t /usr/bin/ssh -q -x -o StrictHostKeyChecking=no -2 \ -l ${SSHUserName} -p 22 ${mainHost} \ | tee >(/opt/oss/clilogging/bin/clilogging.sh…
Jeff7566
  • 432
  • 1
  • 5
  • 20
0
votes
2 answers

What does this command does in shell linux

TMPFILE=/tmp/jboss_ps.$$ ${PS} ${PS_OPTS} | \ grep ${JBOSS_HOME}/java | \ egrep -v " grep | \ tee | $0 " | ${AWK} '{print $NF " "}' | \ sort -u > ${TMPFILE} 2>/dev/null I want to know what this precise line is doing from…
user2548720
  • 109
  • 2
  • 2
  • 7
0
votes
3 answers

Command prompt appearing during execution of a bash script

This is a simplified version of a script I use: In its simplified version tt should read the file input line by line and then print it to the standard output and also write to a file log. input file: asas haha asha hxa The script (named…
Pawel P.
  • 3,731
  • 4
  • 20
  • 20
0
votes
1 answer

Ambiguous output redirect on solaris

I'm running Java program on solaris and want to redirect both standout and standerr to a log file while still keeping them in the console. Here's the command I use: Java -jar MyProgram.jar 2>&1 | tee build.log However, it gives me the following…
Terry Li
  • 16,870
  • 30
  • 89
  • 134
0
votes
0 answers

Tee::FlushToDisk : Timeout flushing queued prints

I'm running a program which generates a log file on Ubuntu 12.04. The log file is sometimes complete, and sometimes it's cut off at random places. I see this error "Tee::FlushToDisk : Timeout flushing queued prints". I'm not calling tee explicitly,…
m126531
  • 265
  • 1
  • 3
  • 11
0
votes
2 answers

Shell: sed pipeline

I'm trying to make a script that redirects data from a serial port to other one. I have realizate it using this command: cat /dev/ttyS0 > /dev/ttyS1 Everything works but, now I would also logging data. I thought I'd use the tee command:    cat…
0
votes
2 answers

is there a way to pipe STDERR and STDOUT to different programs?

For example I need to set two tee commands in such way that one will be reading from STDOUT and second from STDERR and both redirecting the console output to different files. Is such thing possible in windows batch files ? I know about how to…
rsk82
  • 28,217
  • 50
  • 150
  • 240
0
votes
1 answer

bash, tee in a named pipe?

The following code: #!/bin/bash -x mkfifo pipe 2>/dev/null tee pipe >/dev/null & cat pipe produces no output when run as follows: $ echo "hi" | ./test.sh + mkfifo pipe + cat pipe + tee pipe $ Why?! I would expect tee to copy stdin to the named…
Matei David
  • 2,322
  • 3
  • 23
  • 36
0
votes
2 answers

Copy standard input, run two tasks, while reserving the order of output lines?

I want to write a one-line-command to do two tasks with the same copy of stdin. Here is the example: % echo "Victor\nHugo" | tee >(wc -l) | grep "V" The result will finally saved into a file, to be processed by my program. And what I expect to get…
sleepsort
  • 1,321
  • 15
  • 28