어허

sed 명령어 사용법 본문

개발/Linux

sed 명령어 사용법

AKDK 2011. 11. 11. 14:00
728x90

doc 문서로 정리했던 내용

>> sed 명령어 사용법

[injeuniv@laon2 hello]$ cat in.file

hello

say ho

goodbye

[injeuniv@laon2 hello]$ echo "1234hello5678" | sed "s/hello/goodbye/"

1234goodbye5678

                      # hello goodbye로 바꾸어 표준 출력에 출력한다.

[injeuniv@laon2 hello2]$ sed "/hello/d" in.file

say ho

goodbye

 

[injeuniv@laon2 hello2]$ grep -v hello in.file

say ho

goodbye

 

[injeuniv@laon2 hello2]$ sed "s/hello//" in.file

 

say ho

goodbye

 

[injeuniv@laon2 hello2]$ sed "/hello/,/goodbye/s/say/putyourhandsup/g" in.file

hello

putyourhandsup ho

goodbye

                                 # hello 부터 goodbye 라인 까지 say 를 찾아서 putyourhandsup으로 치환

 

[injeuniv@laon2 hello2]$ sed "s/hello/goodbye" in.file

sed: -e expression #1, char 15: unterminated `s' command

 이 오류가 해결이 안된다. 구분자를 /(슬래쉬) 말고 | 나 다른걸로 해보라고 해서 해봤는데도 안됨

어쨌든 sed stream editor로 파일내용을 수정해 표준 출력에 출력해주고 파일내용을 수정할 수도 있다.

http://wiki.kldp.org/Translations/html/Sed-KLDP/index.html

 

728x90
"이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다."
공유하기 링크
Comments