How To Install Sed On Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora And Raspbian?
Maintainer: Clint Adams
Email: [email protected] .
Website: https://www.gnu.org/software/sed/
Section: utils
Install sed
-
Debian
apt-get install sedClick to copy -
Ubuntu
apt-get install sedClick to copy -
Alpine OS
apk add sedClick to copy -
Arch Linux
pacman -S sedClick to copy -
Kali Linux
apt-get install sedClick to copy -
CentOS
yum install sedClick to copy -
Fedora
dnf install sedClick to copy -
Raspbian
apt-get install sedClick to copy
Edit text in a scriptable manner.
How to use sed?
Below are few example commands for sed that you can use in the terminal.
Replace the first occurrence of a regular expression in each line of a file, and print the result:sed 's/regex/replace/' filenameClick to copyReplace all occurrences of an extended regular expression in a file, and print the result:sed -r 's/regex/replace/g' filenameClick to copyReplace all occurrences of a string in a file, overwriting the file (i.e. in-place):sed -i 's/find/replace/g' filenameClick to copyReplace only on lines matching the line pattern:sed '/line_pattern/s/find/replace/' filenameClick to copyDelete lines matching the line pattern:sed '/line_pattern/d' filenameClick to copyPrint only text between n-th line till the next empty line:sed -n 'line_number,/^$/p' filenameClick to copyApply multiple find-replace expressions to a file:sed -e 's/find/replace/' -e 's/find/replace/' filenameClick to copyReplace separator / by any other character not used in the find or replace patterns, e.g., #:sed 's#find#replace#' filenameClick to copy
Installing sed command is simple. just copy one of the above commands for your operating system and paste it into terminal. This command is available for Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora and Raspbian operating systems. Once you run the command it will install the latest version of sed 2026 package in your OS.




