cleanUrl: "linux-sed"
description: "Quick introduction to SED"

생물정보학 연구에 있어서 텍스트 파일을 읽고 수정하는 등 빠르게 처리하는 것은 매우 중요하다. 이를 위해 대학원 신입생 시절 GitHub에 정리해둔 SED 학습 문서(https://github.com/dohlee/learn-sed#regular-expressions)를 옮겨왔다.

Contents

What is SED?

SED stands for Stream EDitor, developed by Lee E. McMahon of Bell Labs. SED can be used for text manipulation, such as text substitution, selective line deletion, and selective line output. Although there exists another powerful stream editing tool, awk, you still can solve any text transformation task with SED. In this tutorial, we will focus on solving many real-life task with SED.

SED cycle

You should be acquainted with the workflow of SED in order to write your SED codes proficiently. When you type SED commands and hit ENTER , the internal structure of SED program looks as below:

https://github.com/dohlee/learn-sed/raw/master/img/sed_cycle.png

Details

  1. Read: Read a line from input stream(e.g. stdin, text file, pipe, ...). The line will be stored in pattern buffer, at which SED commands will be executed.
  2. Execute: Execute SED commands in pattern space.
  3. Display: Display the result of execution to stdout.