Questions tagged [tee]

tee is a command line utility that reads the standard input and writes to the standard output as well as a file specified as an argument. Use this tag for questions about the tee command.

Filter by
Sorted by
Tagged with
2 votes
2 answers
161 views

How to use tee to append to start of file, as opposed to last?

I'm using this bash command to append data to a markdown file: echo "${{ env.PR_TITLE }}" | tee -a page1.md. I was wondering if I could append the echo statement to page1.md at the start, so ...
user avatar
  • 127
0 votes
1 answer
32 views

How to get color in terminal but no color in output file [duplicate]

To show output in both terminal and to a file, tee can be used like below ls --color=auto | tee opfile But now, there is no color in the terminal. If I force colors, opfile also has colors which ...
user avatar
  • 4,049
0 votes
0 answers
38 views

2>&1 | tee cannot get full output log

I'm using the timeout command to call my application in timeout duration. And I also use 2>&1 | tee to write the log in my application to a log.txt file. The command: timeout 20 my_application ...
user avatar
0 votes
0 answers
43 views

How to capture output of tool in real time (tee doesn't seem to do the trick) [duplicate]

For most tools that produce output, I just use tee to capture its output in real-time. However, I am using a tool that seems to spit out its results to the terminal, but tee doesn't send the results ...
user avatar
3 votes
2 answers
166 views

leave color in stdout but remove from tee

I want to see color output when in stdout to the console, but I want to remove it in a captured copy of the output from the tee command.  In my case, command_that_writes_color_to_stdout | tee file I'd ...
user avatar
  • 153
0 votes
3 answers
107 views

exporting global variable in tee process substitution subshells [closed]

command | tee >(var="$(command1)") >(var1="$(command2)") echo "$var $var1" Also tried moreutils pee command | pee 'var="$(command)"' 'var1="$(...
user avatar
0 votes
1 answer
139 views

get count of lines while in pipe

i have a bash script that looks like this: some_process | sort -u | other_process >> some_file I'd like to get the line count to while i'm streaming the data, after the data is sorted but ...
user avatar
  • 195
29 votes
2 answers
2k views

Why does 'ping' not output a summary when redirecting output?

I can ping google.com for several seconds and when I press Ctrl + C, a brief summary is displayed at the bottom: $ ping google.com PING google.com (74.125.131.113) 56(84) bytes of data. 64 bytes from ...
user avatar
  • 1,577
6 votes
1 answer
388 views

tee iso contents into dd or directly to /dev/sda?

Over a year back, I contributed to a tutorial on how to install NixOS on Linode. It seems like most tutorials that deal with putting iso files on installation media always use dd, which is why "...
user avatar
1 vote
0 answers
22 views

How to split a stream to two binaries with retry?

I have a binary that produces an audio stream in s16le format. I want to split this stream to two different processes, but I don't want the command to exit and interrupt process 1 if process 2 errors. ...
user avatar
0 votes
1 answer
119 views

Get hash from file while you copy or move it

Say I copy a file with pv, is there any way to also get any hash, like md5, sha1, etc without having to read origin twice? It has to work with big files or block devices. Example command which does ...
user avatar
0 votes
1 answer
115 views

How might I direct the output of "wget -qO- whatever.tar.gz" to both tar and sha256sum?

The following creates csfile with a hash in it, unpacks go1.17.4.linux-amd64.tar.gz downloaded from Golang's official website, prints out the checksum to stdout and then removes the no longer needed ...
user avatar
0 votes
1 answer
19 views

Piping JShell REPL through tee

If possible, I would like to pipe JShell REPL through tee in the following manner: jshell | tee "~\jshell-`date +'%d_%m_%Y__%H-%M-%S'`.log" The command executes and Shell launches but no ...
user avatar
  • 283
4 votes
1 answer
236 views

tee in for loop not working as expected

I'm trying to use tee in a for loop as such: for ea in $(ls *bam) do samtools mpileup -f $ref $ea | \ tee \ >(java -jar $varscan2 mpileup2indel --output-vcf 1 > vcf/"$(echo $ea | sed ...
user avatar
2 votes
2 answers
258 views

Can we use $PIPESTATUS with the tee (or pee) command?

In my bash scripts, I often use pipes and would like to know which stage of the pipe was causing the problem in case of errors. The basic structure of such snippets is: #!/bin/bash ProduceCommand 2&...
user avatar
  • 2,213
2 votes
3 answers
367 views

Is there a way to send all shell script output to both the terminal and a logfile, *plus* any text entered by the user?

I want to send output of a shell script, including user-entered text, to the terminal and a logfile. I thought some combination of tee and exec might do it, but I’ve had no luck so far. I know tee by ...
user avatar
0 votes
0 answers
19 views

Using tee in apache error logs to write to local and also syslog but date function is not working

In apache httpd.conf This works: ErrorLog "|/var/apache/bin/rotatelogs -f /usr/HTTPLogs/apache/errors.%Y.%m.%d 86400 Output: -rw-r----- 1 root system 48919 Sep 10 12:08 errors....
user avatar
  • 1
0 votes
1 answer
69 views

BASH 4: tee to log file, fail over to /dev/null

I have a script that attempts to log its actions. There's a single tee in there that does all of this. Currently, when the $LOG_FILE cannot be written to the script dies. Instead, I would like it to ...
user avatar
2 votes
1 answer
151 views

Can named pipes/FIFOs be used in a "cyclic" manner together with `tee`?

Why does the last line in this script gets stuck? #!/usr/bin/env bash trap 'rm -f numbers' EXIT mkfifo numbers decrement() { while read -r number; do echo "debug: $number" >&...
user avatar
0 votes
0 answers
19 views

Userspace solution to use store data and create a UDP server

I'm trying to come up with a good way manage an intermittently connected device that I'm using for a research project. It's a sensor that goes in and out of the water. While under water, of course, ...
user avatar
  • 111
4 votes
1 answer
66 views

What's wrong with this branched data flow using `tee`, fifos, and `paste`?

In the spirit of this question, I want to create a branched data flow from a single source: cmd1 ──> tee ──────────────> │    ├─────> cmd2 ─────> │ cmd4       └─────&...
user avatar
1 vote
0 answers
65 views

bash grep in a tee

I am trying to write a log file and output to a console at the same time The below works well. However I have a sleep timer and the logfile counts down each second and fills the log. The "...
user avatar
  • 11
5 votes
1 answer
663 views

How to redirect a command's `stdin` as well as `stdout` to the output

Suppose I have the Python script: #!/usr/bin/env python input('Y/n: ') print('Next line') After I press Y, I want both the terminal and my output.txt containing: Y/n: Y Next line Running the ...
user avatar
  • 613
0 votes
1 answer
99 views

Having the output printed on the screen and redirected to a file and forwarded the errors to another file

I’m trying to answer this lab question. Is there a way to solve this without using tee command? As user1 on server1, run the ls command on /etc, /dvd, and /var. Have the output printed on the screen ...
user avatar
  • 11
2 votes
4 answers
569 views

Pipe result to multiple commands without writing on screen

I have a very big zip file (~10 GB) which I want to unzip, and the result has to be passed to two commands. The results of both subsequent commands have to be appended to a file, and Currently, I run ...
user avatar
4 votes
1 answer
503 views

why does tee refuse to work when launched remotely via ssh?

Where is my error? As an answer to a Stackexchange question, I tar a directory and transfer the archive to a remote system, where tee both deposits in a file and pipes it to tar for unpacking. My ...
user avatar
  • 3,115
0 votes
1 answer
50 views

Get the output of a remote ssh to local

I'm able to get the output of a failing lp command from a remotehost to my local script like below: until ssh -q root@remotehost 'lp -d Brother_HL_L2350DW_series /root/moht/Printed/`basename "$...
user avatar
  • 307
1 vote
1 answer
330 views

How to uncompress a gzipped partition image and dd it directly to the destination partition without writing to current partition?

I've backed up a partition using sudo dd bs=8M if=/dev/sda2 | gzip > /someFolderOnSDB/sda2.img.gz. The image is stored on a separate disk sdb. When restoring it using gunzip -k /mnt/bkp/sda2.img.gz ...
user avatar
  • 325
1 vote
1 answer
301 views

BusyBox tee is very slow

I am using Puppy-4.3.1 Linux on some older (Pentium 4) hardware. I am getting terrible performance out of the tee command. On this distro, tee is part of BusyBox v1.15.0. For example, this command ...
user avatar
  • 215
2 votes
1 answer
85 views

How to pipe output of command to two separate commands and store outputs

I have a really long command that runs over a huge file and I am forced to run it twice which doubles the time it takes to run. This is what I am doing at the moment: x=$(command | sort -u) y=$(...
user avatar
2 votes
1 answer
679 views

Is it safe to pipe multiple commands output to the same file simultaneously using tee?

I am piping the output from multiple commands into the same file simultaneously using terminal like this: cmd1 | tee -a /tmp/file cmd2 | tee -a /tmp/file cmd3 | tee -a /tmp/file Is it safe to use? ...
user avatar
1 vote
1 answer
42 views

tee pipeline and pnmtools - truncated file

This sequence of commands works OK: pngtopnm file.png 2> /dev/null > dump1 pnmfile < dump1 stdin: PPM raw, 1920 by 1080 maxval 255 ls -l dump1 -rw-r----- 1 cmb 6220817 Sep 15 14:26 dump1 ...
user avatar
  • 113
0 votes
1 answer
61 views

how to build lightweight continous connection monitoring using ping?

I want to build a connection monitor script using ping that sends off, let's say 10 pings every so often(~once an hour) 24/7 and record the output to a file for later analysis. So far, I've got the ...
user avatar
  • 205
0 votes
2 answers
198 views

Why does dd if=/dev/sdb | pigz -c | tee /sdb.img.gz print to console?

The command sudo dd if=/dev/sdb | pigz -c | sudo tee /sdb.img.gz (omitted sudo in the title) prints binary data to console either the output of dd or pigz. I'm wondering why since all output are ...
user avatar
0 votes
2 answers
1k views

Bash: Eval & Tee: how to have Output, Captured Output and Error Check

using #!/bin/bash under Ubuntu 16.04 I want to an eval'ed command to... deliver direct output get the output to a variable check on the result of the eval # valid command foo=$(eval "ls" | ...
user avatar
1 vote
2 answers
534 views

Output tee to stdout while writing to a FD using here-strings

I am trying to output tee while writing to a custom file descriptor. Example: exec 4>"/tmp/testfile.txt"; # open FD 4 tee -a >&4 <<< "Output this to stdout" # ...
user avatar
  • 113
1 vote
1 answer
371 views

Systemd service does not save changes to disk

Wrote a simple keychron.service file to overwrite a parameter during each boot-up. [Unit] ...
user avatar
  • 113
2 votes
3 answers
81 views

Tool to play back pipe including timing

tee stores a copy of stdin in a file, so you later can cat that file. Is there a tool that can do this but also record and play back the timing? So I want: $ (echo foo; sleep 1; echo bar) | the-...
user avatar
  • 29.8k
6 votes
1 answer
161 views

How do I move the last 3 lines of a pipeline to the top of the output with ed?

I have a small AWK script that summarizes the output of another program, and I am trying to print that summary before the command itself, but I cannot figure out a good way to do it. My naive first ...
user avatar
  • 63
3 votes
2 answers
1k views

What is a tee equivalent for network packets? [closed]

This is probably a very basic question. Wanted to know in Linux if there is a command that could work like the tee command but for forwarding TCP/UDP packets. Basically it should listen at one port ...
user avatar
1 vote
1 answer
100 views

duplicate output of more commands

#!/bin/bash VAR1="Hello" VAR2="Bye" { echo $VAR1 some stuff here echo $var2 } mutt -s "this is a test" destination@gmail.com I need to duplicate (maybe using tee ...
user avatar
  • 1,839
3 votes
1 answer
2k views

How to capture error of failed command with message using tee command

I want to capture and write my error to log file along with custom message. Consider the command : $(find $val -type f -delete) || echo "error in deleting files" |tee -a log.txt This command writes ...
user avatar
  • 127
0 votes
0 answers
30 views

Wheel user with sudo permissions can't write to file with tee, but can create it. How to fix? [duplicate]

This is my output on CentOS. [test@test]$ sudo fallocate -l 2M text [test@test]$ sudo echo “This is for test” | tee text tee: text: Permission denied “This is for test” [test@test]$ ls text [test@...
user avatar
  • 217
0 votes
1 answer
433 views

How to print intermediate result of commands in a pipeline?

I have a series of commands running through a pipeline like this: cmd1 | cmd2 | cmd3 | cmd4 How can I print the intermediate result of cmd1, cmd2 and cmd3? I know I can use the tee command to print ...
user avatar
1 vote
1 answer
562 views

Write only differences with watch -d command

I have to use watch in order to write in a file (doc.txt) the differences between a new version of a file and an older. I tried watch -t -d -n 10 "cat myfile.txt | tee doc.txt" but all myfile.txt's ...
user avatar
  • 11
1 vote
1 answer
509 views

How do I use tee and named pipes?

I'm trying to come up with a simple command that reads an image and displays it, while simultaneously writing it to the clipboard. This is what I've tried and how it failed: cat pic.png | tee >(...
user avatar
  • 519
2 votes
1 answer
118 views

Using tee and paste results in a deadlock

I am trying to redirect stdout of a command into two "branches" using tee for separate processing. Finally I need to merge results of both "branches" using paste. I came up with the following code for ...
user avatar
1 vote
1 answer
896 views

Piping to multiple awk commands

I'm trying to pipe the output of one command to two different awk commands. Following this post I am using tee and process substitution. However, I can't see the output for the substituted process. ...
user avatar
  • 15
1 vote
1 answer
234 views

Is there a command that combines `tee` and `grep` such that in a pipeline the tee part can direct matches to a file?

I'm looking to pull multiple pieces from a file, or at least watch for pieces in a log file if they should occur, but I don't want to setup multiple tail | grep sessions. Instead I'd like to just ...
user avatar
  • 2,449
0 votes
1 answer
309 views

grep not matching in nc output - tee gives no output

See original Q&A about grep not accepting netcat output on stderr at a prior StackExchange post. Concise answer. I like it. Why does adding a tee on the end fail to produce any output? nc -zvv ...
user avatar
  • 29

1
2 3 4 5