강좌
클라우드/리눅스에 관한 강좌입니다.
리눅스 분류

cat명령어로 특정파일의 내용확인 시에 두개이상의 빈행이 연속될 때에 한행만 출력하기

작성자 정보

  • 관리자 작성
  • 작성일

컨텐츠 정보

본문

cat명령어로 특정파일의 내용확인 시에 두개이상의 빈행이 연속될 때에 한행만 출력하기

 

cat명령어로 행 번호를 붙여서 파일의 내용을 확인할 때에 -s옵션을 사용하면 파일의 내용 중 빈행이 2행이상 연속될 경우에는 한 행만을 출력하게 됩니다.

 

 

 

  -s옵션과 -n옵션을 함께 적용하면 2행이상의 빈행이 있을 경우에는 행번호를 1개만 붙이게 됩니다.

 

 

 

  다음의 예를 보겠습니다.

 

 

 

 

 

[root@su250 ~]# cat textfile

Based upon the NCSA server

configuration files

originally by Rob McCool.

 

This is the main Apache server

configuration file.

 

 

It contains the configuration directives

that give the server

its instructions.

[root@su250 ~]#
[root@su250 ~]# cat -s textfile

Based upon the NCSA server

configuration files

originally by Rob McCool.

 

This is the main Apache server

configuration file.

 

It contains the configuration directives

that give the server

its instructions.

[root@su250 ~]#
[root@su250 ~]# cat -sn textfile

     1  Based upon the NCSA server

     2  configuration files

     3  originally by Rob McCool.

     4

     5  This is the main Apache server

     6  configuration file.

     7

     8  It contains the configuration directives

     9  that give the server

    10  its instructions.

[root@su250 ~]#

 

, 위의 예는 비어있는 행도 하나의 행으로 취급하면서(-n) 중복되는 빈 행을 하나의 행으로만 취급(-s) 하면서 textfile파일의 내용을 출력한 것입니다.

 

 

 

관련자료

댓글 0
등록된 댓글이 없습니다.

공지사항


뉴스광장


  • 현재 회원수 :  60,032 명
  • 현재 강좌수 :  35,773 개
  • 현재 접속자 :  268 명