"리눅스 파일 특정 행 보기"의 두 판 사이의 차이

잔글
1번째 줄: 1번째 줄:
*리눅스 파일에서 N번째 행 출력
;리눅스 파일에서 N번째 행 출력
*리눅스 파일에서 N번째 행 보여주기
;리눅스 파일에서 N번째 행 보여주기
*리눅스 파일에서 N번째 행 가져오기
;리눅스 파일에서 N번째 행 가져오기


==기본==
==기본==
27번째 줄: 27번째 줄:
Kernel \r on an \m
Kernel \r on an \m
</source>
</source>
==같이 보기==
*[[리눅스 첫번째 매칭 행번호 확인]]


[[분류:리눅스]]
[[분류:리눅스]]

2012년 7월 11일 (수) 13:48 판

리눅스 파일에서 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 }}