← All commands
Topic hub PowerShell Equivalents
Windows Linux PowerShell Equivalents Text Processing

Windows PowerShell Tee-Object equivalent in Linux

Copies piped output both to the terminal and to one or more files.

Windows PowerShell Tee-Object
Linux equivalents
Debian/Ubuntu same command
command | tee output.txt
Fedora same command
command | tee output.txt
Arch same command
command | tee output.txt

Overview

What this command does

Copies piped output both to the terminal and to one or more files.

Migration tip: tee -a appends rather than replacing. It is also the standard way to write piped data through sudo.

Practical tasks

Common use cases

Display and save output

Copies piped output both to the terminal and to one or more files.

ls -la | tee listing.txt

Display and save

date | tee -a history.txt

Append while displaying

printf "%s\n" "value" | sudo tee /etc/example.conf

Write a protected file

Ready to run

Copyable Linux commands

Review paths, device names, package names and permissions before running any command.

ls -la | tee listing.txt
date | tee -a history.txt
printf "%s\n" "value" | sudo tee /etc/example.conf

Walkthrough

Examples with explanations

ls -la | tee listing.txt # show and save output
date | tee -a history.txt # append and display
printf "%s\n" "value" | sudo tee /etc/example.conf # write through sudo

Reference

Common options and variations

Command or optionUse
ls -la | tee listing.txtDisplay and save
date | tee -a history.txtAppend while displaying
printf "%s\n" "value" | sudo tee /etc/example.confWrite a protected file

Distro differences

Debian/Ubuntu vs Fedora vs Arch

This command is the same on Debian/Ubuntu, Fedora and Arch Linux when the relevant tool is installed.

DistributionPackage manager / baseEquivalent commandDifference to notice
Debian/Ubuntu same command command | tee output.txt Same command on this distribution.
Fedora same command command | tee output.txt Same command on this distribution.
Arch same command command | tee output.txt Same command on this distribution.

Keep learning

Related PowerShell Equivalents commands