Replace text in a file with sed

Replace every match of a string directly in the file.

sed -i 's/old-string/new-string/g' file.txt

tool
linux133 commands
tags
linux

More linux commands

  • sort file.txt | uniq -c | sort -rn | head -20

    Count how often each line repeats in a file and show the top 20.

  • lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,UUID

    Show disks, partitions and loop devices as a tree with filesystem type, mount point and UUID.

  • blkid

    Print UUID, LABEL and TYPE for every block device.

  • mount -t ext4 /dev/sdb1 /mnt/data

    Mount an ext4 partition to /mnt/data.

  • findmnt --real

    Show real (non-virtual) mounted filesystems as a tree.

all 133 linux commands