Forrest logo
tool overview
On this page you find all important commands for the CLI tool sed. If the command you are looking for is missing please ask our AI.

sed

SED command in UNIX stands for stream editor and it can perform lots of functions on file like searching, find and replace, insertion or deletion. Though most common use of SED command in UNIX is for substitution or for find and replace. By using SED you can edit files even without opening them, which is much quicker way to find and replace something in file, than first opening that file in VI Editor and then changing it.

List of commands for sed:

  • file_manipulation:warp:63a4e7ade76260ddef0e586180a62531 Insert a line at a specific line number
    $ sed -i '' '${line_number}i\
    $ ${line_number} ${text}' ${file_name}
    try on your machine
    explain this command
  • file_manipulation:warp:be41aa3050d444ffa85e681aa5962dc5 Delete all lines that contain a specific string from a text file
    $ sed -i '' '/${string}/d' ${file}
    try on your machine
    explain this command
  • file_manipulation:warp:d071fbbca6930a159e0a53c168b52ef7 Print the nth line of a file
    $ sed '${line_number}q;d' ${file_path}
    try on your machine
    explain this command
  • file_manipulation:warp:e6754b24398f1b178804d18fadc5c82b Delete empty lines in a file
    $ sed '/^[[:space:]]*$/d' ${file_name}
    try on your machine
    explain this command
  • files:edit:remove:line-number Deletes the line number X from the file.txt
    $ sed -i 'Xd' ${filename}
    try on your machine
    explain this command
  • linux:files:file:delete:line Delete a single line from a given file
    $ sed -i '${line_number}d' ${filename}
    try on your machine
    explain this command
  • sed:tldr:33c7c sed: Replace all `apple` (basic regex) occurrences with `mango` (basic regex) in a `file` and save a backup of the original to `file.bak`.
    $ sed -i bak 's/apple/mango/g' ${filename}
    try on your machine
    explain this command
  • sed:tldr:d36c1 sed: Replace all `apple` (basic regex) occurrences with `mango` (basic regex) in a specific file and overwrite the original file in place.
    $ sed -i 's/apple/mango/g' ${filename}
    try on your machine
    explain this command
  • ssh:authorized-keys:remove Removes a single authorized key from the ~/.ssh/authorized_keys file
    $ sed -i '${key-to-remove}' ~/.ssh/authorized_keys
    try on your machine
    explain this command
tool overview