Windows PowerShell Tee-Object equivalent in Linux
Copies piped output both to the terminal and to one or more files.
PowerShell Tee-Object
command | tee output.txt
command | tee output.txt
command | tee output.txt
Overview
What this command does
On Windows, "PowerShell Tee-Object" is used to display and save output. On Linux, the closest practical mapping shown here is "command | tee output.txt". Copies piped output both to the terminal and to one or more files. This reference is grouped under PowerShell Equivalents → Text Processing.
Windows → Linux context
What changes when you use this on Linux?
Equivalent task, different tool
Windows PowerShell Tee-Object maps to command | tee output.txt for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.
Portable across the compared distros
The Debian/Ubuntu, Fedora and Arch rows use the same command in this mapping. Package availability or defaults can still vary, so check the installed tool version when an option behaves differently.
For the broader concept behind this mapping, read PowerShell vs Bash.
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
Debian/Ubuntu, Fedora and Arch all use "command | tee output.txt" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.
| 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