[jellypo@localhost ~]$ cat test
start
#test hello wolrd
end
[jellypo@localhost ~]$ sed -e 's,\(\#test.*\),\1\ninsert,g' test
start
#test hello wolrd
insert
end
#test 패턴이 한 줄에 여러번 나와도 한 번 적용되네요.
[jellypo@localhost ~]$ cat test
start
#test hello #test wolrd
end
[jellypo@localhost ~]$ sed -e 's,\(\#test.*\),\1\ninsert,g' test
start
#test hello #test wolrd
insert
end
\n 뒤에 삽입할 문자를 넣으세요.
#test 패턴이 한 줄에 여러번 나와도 한 번 적용되네요.
아!!!
감사합니다!
근데 혹시 #test 는 안지워지게 안될까요?
치환이 아니라..
그냥 밑에 계속 추가를 하고 싶어서요
지금 올려놓은게
지금 올려놓은게 치환이 아닌 추가인데요?
code 부분에 보면 실행 결과 있잖아요.
cat 원본
sed 's,\(\#test\.*),\1\n추가할 내용,g' 원본
#test는 안 건드리고 그 아랫줄에 추가하고 있습니다.
아.. 죄송합니다
멋대로 테스트를 해서 결과가 ;;;
감사합니다~~~
댓글 달기