리눅스 파일 특정 행 보기

Jmnote (토론 | 기여)님의 2012년 9월 17일 (월) 09:52 판 (→‎같이 보기)
리눅스 파일에서 N번째 행 출력
리눅스 파일에서 N번째 행 보여주기
리눅스 파일에서 N번째 행 가져오기

1 기본

  • test.txt 파일에서 10번행 가져오기
sed -n 10p < test.txt

2 고급 (성능향상)

  • test.txt 파일에서 10번행 가져오기. (더 빠르게 하기)
sed -n '10p;11q' < test.txt

11번행에서 탐색을 종료하여 속도를 높힌다.

3 실행예시

[root@localhost ~]# cat /etc/issue
CentOS release 5.7 (Final)
Kernel \r on an \m

[root@localhost ~]# sed -n 2p /etc/issue
Kernel \r on an \m
[root@localhost ~]# sed -n '2p;3q' /etc/issue
Kernel \r on an \m

4 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}