Skip to main content

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.

15 votes
2 answers
2k views

Why does "seq 1000000 | tee /dev/stdout" produce more single-digit numbers than expected?

I'm in Linux and in Bash. I expect seq 1000000 | tee /dev/stdout to always output 9 numbers from 1 to 9 and their duplicates (18 in total). But when I do seq 1000000 | tee /dev/stdout | grep -c '^[1-...
decision-making-mike's user avatar
0 votes
0 answers
34 views

Why does `<command> | tee /dev/tty | :` (where `:` is the "no effect" or "does nothing" bash builtin) display nothing? [duplicate]

I wanted to use tee /dev/tty to look into the stream passing through a pipeline. While making some tests, I observed the following: ~$ cd /proc/self/fd /proc/self/fd$ ls 0 1 2 255 # Ok /proc/self/...
The Quark's user avatar
  • 454
5 votes
2 answers
330 views

Duplicate stdout to pipe into another command with named pipe in POSIX shell script function

mkfifo foo printf %s\\n bar | tee foo & tr -s '[:lower:]' '[:upper:]' <foo wait rm foo This is a working POSIX shell script of what I want to do: printf %s\\n bar is symbolic for an external ...
finefoot's user avatar
  • 3,554
2 votes
2 answers
507 views

what is the meaning and usage of 2>&1 | tee /dev/stderr

for the following command output=$(cat $file | docker exec -i CONTAINER COMMAND 2>&1 | tee /dev/stderr) what is the meaning and usage of 2>&1 | tee /dev/stderr? I google and 2>&...
user1169587's user avatar
1 vote
1 answer
243 views

bash: script running in pm2 unable to access file descriptors files at /dev/fd/

I have script script.sh: #!/usr/bin/env bash # pm2 seems to always run in `bash` regardless of `#!` echo "running in $(readlink -f /proc/$$/exe)" # Redirect to both stdout(1) and stderr(2) ...
Amith's user avatar
  • 313
0 votes
1 answer
101 views

How can I get stderr from mbuffer written to log file when using tee?

Having a bash script that essential only doing: mbuffer --md5 -i dummy.tar -o /dev/null A user of this script wants to use tee and store the output messages in a log file. ./script.sh 2>&1 | ...
TopCatSE's user avatar
0 votes
1 answer
157 views

can tee 'save' to stderr?

I know how to use tee, of course, I have used it many times. However, it is normally something like: du -h /some/directory | sort -h | tee census While this works fine, it means I don't see anything ...
j4nd3r53n's user avatar
  • 779
0 votes
1 answer
213 views

Use grep to search stdout, without replacing stdout

At the moment, I have this in a wrapper script: 2>&1 ./update.sh | ts | tee -a ./update.log and this in update.sh: if apt full-upgrade -y | grep linux-headers then echo echo Need to ...
AaronD's user avatar
  • 153
8 votes
1 answer
1k views

What is the '.tee_history' file?

This is a plaintext file, apparently limited to 300 lines. I use tee frequently on my system. $ file .tee_history .tee_history: Unicode text, UTF-8 text $ wc -l .tee_history 300 .tee_history $ tee --...
user598527's user avatar
2 votes
1 answer
163 views

How to "render" ouput from a command playing with tput so only the final terminal-postprocessed result is kept? [duplicate]

I captured the output of a script that uses tput to draw certain things on screen. When I perform cat myoutput then everything is well seen (looks like terminal reinterprets it from beginning), but ...
Whimusical's user avatar
0 votes
1 answer
176 views

Why is tee stopping in the middle when piped with nohup?

I'm running a script (in a Laravel project) that takes a few hours to complete. nohup to prevent it from exiting if my ssh session is disconnected. nohup php artisan do:thing 2>&1 | tee ~/tmp ...
Jeremy Belolo's user avatar
-1 votes
1 answer
99 views

What does the tee l2r or r2l argument mean?

I saw a socat example here, where they use tee l2r | socat - "TCP:remote:5555" | tee r2l what does the l2r or r2l mean?
René Link's user avatar
0 votes
1 answer
98 views

Can I use tee to display output that other utilities tend to suppress?

The macos pbcopy utility grabs its input stream and stores it in the system clipboard, without displaying anything. So, when I want to copy/paste the output of a command in the terminal, I typically ...
JL Peyret's user avatar
  • 115
19 votes
3 answers
15k views

What is the `tee` command in Linux?

I am trying to interpret the following tee command: cat colors.txt words.txt | tee colorsAndWords.txt | wc Is my understanding, as follows, correct? cat colors.txt words.txt: This command ...
Nosail's user avatar
  • 291
2 votes
2 answers
302 views

tee /dev/stderr inside script truncates output file if you redirect stderr

Given a script like below if I try to redirect stderr to a file, then the file is truncated at the point tee is used: $ cat test.sh #!/bin/bash set -eux echo before echo '{ "foo": "...
Jakub Bochenski's user avatar

15 30 50 per page
1
2 3 4 5
16