מדריך Sed


ניתן למצוא גירסת טקסט של המדריך עם רוב הדוגמאות בקישור:
https://www.tocode.co.il/blog/2022-07-sed-tutorial

Sed Guide

How It Works

  • sed program structure (in file)
  • sed program structure (command line)
  • Basic commands: p, d, s, w, r

  • last line - $

  • select line by regexp - /.../

Simple Examples

  • Show file without first line (i.e. tail +2)
  • Show only first line of file (i.e. head -1)
  • Show only lines that don't start with #
  • add line numbers

Useful Sed Tricks

  • Change hashbang line in all .sh files to #!/bin/bash

  • Change aliases format from csh to bash

  • Create summary from a collection of files

  • Insert hashbang line to all .sh files