← All commands
Topic hub PowerShell Equivalents
Windows Linux PowerShell Equivalents 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

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

Migration tip: Use >> for normal shell appends. Use sudo tee -a when appending to a file that requires elevated privileges.

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

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 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