sed로 특정 문자열의 위나 아래 라인 삭제하는 방법
글쓴이: onepice0410 / 작성시간: 목, 2014/07/03 - 2:57오후
특정 문자열의 위나 아래 라인에 불필요한 내용을 삭제하고 싶은대요
같은내용의 파일이 한두개가 아니라서 혹시 방법이 있을까요?
삭제 전 파일
version 1.1.1 -- 특정 문자열
test test test test -- 삭제하고 싶은 라인
asdf asdf asdf asdf
삭제 후 파일
version 1.1.1
asdf asdf adsf asdf
Forums:
http://stackoverflow.com/ques
http://stackoverflow.com/questions/18620153/find-matching-text-and-replace-next-line
혹은
http://stackoverflow.com/questions/4396974/sed-delete-n-lines-following-a-pattern
여기에 있는 내용을 응용하면 되지 않을까요?
말씀하신 경우는
cat filename | sed '/^version 1.1.1.*/{n;d}'
이렇게 하면 될것 같구요.
감사합니다.
덕분에 문제가 해결됬네요!
댓글 달기