sed(streamlined editor)
: 리눅스 편집에 특화된 유틸리티
라인 출력
1~3행 라인 출력
sed -n '1, 3p' study
1
2
3
5행 ~ 마지막 라인 출력
sed -n '5, $p' study
5
6
7
8
9
10
1행 및 8행 ~ 마지막 라인 출력
sed -n -e '1p' -e '8,$p' study
1
8
9
10
특정 단어로 시작하는 행 출력
“1” 시작하는 문자열 모두 출력
sed -n '/^1/p' study2
1
10
11
12
13
14
15
16
17
18
19
빈 줄 제거
sed '/^$/d' study2 > study3
빈 줄 및 공백 제거
sed '/^ *$/d' study2 > study3
치환
# 10 -> 100 변경
sed 's/10/100/g' study3 > study4
'시리즈 > Linux 기초 다지기 2023 (개편 예정) - 시리즈' 카테고리의 다른 글
리눅스 기초 다지기 - 커맨드 익숙해지기 (echo, source, curl) (0) | 2025.03.13 |
---|---|
리눅스 기초 다지기 - 38. awk (0) | 2025.03.13 |
리눅스 기초 다지기 - 36. editor (vi, nano) (0) | 2025.03.13 |
리눅스 기초 다지기 - 35. 표준 파일 디스크립터 (0) | 2025.03.13 |
리눅스 기초 다지기 - 커맨드 익숙해지기(cat, find, grep, watch, which, whatis) (0) | 2025.03.13 |