Skip to main content

Primary links

  • Home
  • AI
  • Kubernetes
  • Incus
  • Ansible
  • Terraform
  • OpenStack
  • Virtualization
  • Linux
  • SmartHome
  • HowTo

Misc

  • Linux
  • Hardware
  • Programming
  • Databases
  • Multimedia
  • Windows

Cloud

  • OpenStack
  • cloud-config
  • nextcloud

Virtualization

  • Virtualization
  • Incus
  • Docker
  • KVM
  • Kubernetes
  • LXC
  • LXD
  • QEMU
  • VMware
  • VirtualBox
  • multipass
  • podman
  • vagrant
  • XEN

Network

  • DNS
  • Firewall
  • Linux
  • OpenvSwitch
  • SSL
  • VLAN
  • VPN
  • iPXE
  • namespaces
  • nmcli
  • tcpdump

Storage

  • CEPH
  • DRBD
  • LVM
  • S3
  • ZFS
  • btrfs

Automation / CI/CD

  • Install
  • Ansible
  • GitLab
  • LLM
  • Preseed
  • Puppet
  • Terraform
  • Ubuntu autoinstall

Monitoring / Visualisation

  • Grafana
  • Icinga
  • Prometheus
  • Monitoring
  • ELK
  • mermaid
  • linux
# remove 3th line
sed -i 3d 

# insert line on beginning of a file
sed -i '1i MY_TEXT' 

# String replace with sed
sed -i 's|STRING_FROM|STRING_TO|g' 
sed -i 's|[#]*param=[yes|no]*|param=yes|g' 

# search for line and replace value
sed '/ipsum/s/from/to/g'
sed /ipsum/{s/#//g;s/from/to/g;}
sed '/^http/ s/$/>/'

# add line to a file
sed -i '13i\YOUR_TEXT' 

# add line before last line
sed -i '$i test_line' 

# search block
sed -n '/FOO/,/BAR/p' 

# remove digits
echo ${FOO} | sed 's/[^0-9]*//g' 

# remove blanks (trim)
cat  | sed 's/  */ /g'
# remove blanks and tabs
cat  | sed "s/[ \t][ ]*/ /g"
# remove all blanks
cat  | sed -e 's/[\t ]//g;/^$/d'
cat  | sed -e 's/[\t]/ /g;s/  */ /g'
sed -e 's/^[[:space:]]*//'
# trim leading and trailing whitespace
sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//'
# replace first blank
sed -r 's/\s+/,/' file_in
# replace multiple space with singe space
sed 's/  \+/ /g'

# write to file
sed 's/foot/bar/;w file'

# remove leading blank
sed "s/^[ ]*//"

# remove blank at end of line
sed 's/ *$//' file

# remove last comma
sed 's/,$/'

# cat from to
sed -n '/^START/,/^END/p' 

# Uncomment all lines
sed -i 's/^/#/' /etc/locale.gen

# replace key = value
sed -i "s|^tag = .*|tag = ${NEW_VALUE}|g" 

# replace string
echo "my foo bar" | sed -e s/foo//

# uncomment line
sed -i '/foo/s/^#//g' 
sed -i '/foo/, +1 s/^#//g' 

# comment in line
sed -i '/foo/s/^/#/g' 
sed -i '/foo/, +1 s/^/#/g' 

# delete all input lines which are not followed by a line with matching string
sed '$!N;/\n.*foo/d;P;D'

# delete lines
sed '/foo/d'

sed -n '/^foo$/,$p'

# remove string between
sed 's/[_| ].*:/ /g'

# print last line
sed '$!d'

# remove dos line break ^M
sed -e "s/\r//g"

# remove empty line
sed '/^$/d'

# delete string
sed -e "s/^$bar//"

# delete line  contains
sed -i '/Baeldung/d' myfile.txt
# search and replace content in files
for FILE_PATH in $(ls /var/www/*/*/pages/*.html); do
    sed -i -E "/(German|Englisch)/s|/index.html|/portal/${FILE_PATH##*/}|g" ${FILE_PATH}
done
Profiles GitHub StackOverflow LinkedIn Xing
Contact Imprint
© panticz 2026

Cookie-Einstellungen

Diese Website nutzt eingebettete Inhalte von Drittanbietern (z.B. YouTube, SoundCloud). Beim Laden dieser Inhalte werden Daten an die jeweiligen Anbieter übermittelt. Datenverarbeitungserklärung