'빈 라인'에 해당되는 글 1건

  1. 2009.03.01 grep을 사용한 빈라인 지우기

grep을 사용하여 빈라인 지우기

grep 명령어를 사용하여 빈 라인을 지우기 위해서는 다음의 명령을 사용할 수 있다.

grep -v "^ *$" INPUTFILE > OUTPUTFILE(^과 * 사이엔 스페이스가 들어감)

INPUTFILE : 빈라인을 가진 입력파일
OUTPUTFILE : 출력파일(빈라인 제외된)

만일 grep -v "^$" 만을 사용한다면 공백을 포함하는 빈 라인은 제거되지 않을 것이다.

--------------------< 원 문 >--------------------
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

                             UNIX GURU UNIVERSE
                                UNIX HOT TIP

                       Unix Tip 2945 - February 28, 2009

                   http://www.ugu.com/sui/ugu/show?tip.today

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


DELETING BLANK LINES USING GREP

To delete a blank line using a grep command you can use the next
command :-

grep -v "^ *$" file-y > file-x

where file-y is the input files has blank lines and file-x will
be the output file ( excluding the blank lines ).

if we use (  grep -v "^$" ) only , the blanck line which include
spaces will not be removed.

반응형
Posted by She쥐포s
이전버튼 1 이전버튼

블로그 이미지
She쥐포s
Yesterday
Today
Total

달력

 « |  » 2024.3
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31

최근에 올라온 글

최근에 달린 댓글

글 보관함