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
command | tee output.txt
command | tee output.txt
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 option | Use |
|---|---|
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 |
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.
| Distribution | Package manager / base | Equivalent command | Difference 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