← All commands
Topic hub PowerShell Equivalents
Windows Linux PowerShell Equivalents Expanded guide File System

Windows PowerShell Add-Content equivalent in Linux

Adds new text to the end of an existing file without replacing its current contents.

Windows PowerShell Add-Content
→
Linux equivalents
Debian/Ubuntu same command
printf "%s " "text" | tee -a file.txt
Fedora same command
printf "%s " "text" | tee -a file.txt
Arch same command
printf "%s " "text" | tee -a file.txt

Overview

What this command does

On Windows, "PowerShell Add-Content" is used to append content to a file. On Linux, the closest practical mapping shown here is "printf "%s " "text" | tee -a file.txt". Adds new text to the end of an existing file without replacing its current contents. This reference is grouped under PowerShell Equivalents → File System.

Migration tip: Use <code>&gt;&gt;</code> for normal shell appends. Use <code>sudo tee -a</code> when appending to a file that requires elevated privileges.

Windows → Linux context

What changes when you use this on Linux?

Equivalent task, different tool

Windows PowerShell Add-Content maps to printf "%s " "text" | tee -a file.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.

Practical tasks

Common use cases

Append content to a file

Adds new text to the end of an existing file without replacing its current contents.

printf "%s\n" "new line" >> notes.txt

Append using shell redirection

printf "%s\n" "new line" | tee -a notes.txt

Append and display the text

printf "%s\n" "option=yes" | sudo tee -a /etc/example.conf

Append to a protected file

Ready to run

Copyable Linux commands

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

printf "%s\n" "new line" >> notes.txt
printf "%s\n" "new line" | tee -a notes.txt
printf "%s\n" "option=yes" | sudo tee -a /etc/example.conf

Walkthrough

Examples with explanations

printf "%s\n" "new line" >> notes.txt # append one line
printf "%s\n" "new line" | tee -a notes.txt # append while echoing output
printf "%s\n" "option=yes" | sudo tee -a /etc/example.conf # append with root privileges

Reference

Common options and variations

Command or optionUse
printf "%s\n" "new line" >> notes.txtAppend using shell redirection
printf "%s\n" "new line" | tee -a notes.txtAppend and display the text
printf "%s\n" "option=yes" | sudo tee -a /etc/example.confAppend to a protected file

Distro differences

Debian/Ubuntu vs Fedora vs Arch

Debian/Ubuntu, Fedora and Arch all use "printf "%s " "text" | tee -a file.txt" for this mapping. The command syntax shown here is portable across the three rows, although installed versions and system defaults can still vary.

DistributionPackage manager / baseEquivalent commandDifference to notice
Debian/Ubuntu same command printf "%s " "text" | tee -a file.txt Same command on this distribution.
Fedora same command printf "%s " "text" | tee -a file.txt Same command on this distribution.
Arch same command printf "%s " "text" | tee -a file.txt Same command on this distribution.

Keep learning

Related PowerShell Equivalents commands