awk, sed 등으로 문장을 파싱해서 지우고 삽입하려고 합니다

이명수의 이미지

아래와 같은 text 파일이 있습니다

the fruit shop
 
no fruits anywhere
the end.

no fruits anywhere 문장을 파싱해서 지워버리고
그 위치에 3줄의 문장을 삽입하려고 합니다. 어떻게 해야 할까요?
the fruit shop
 
apples in the basket
oranges on the table
melons on the desk
the end.

shell script에서 awk, sed 등은 사용할 수 있고
perl, python 등의 script 언어는 사용할 수 없습니다.

raymundo의 이미지

파싱...이라고 할 것도 없이, 단지 특정한 문장을 다른 문장으로 교체하는 수준이라면

sed "s/^no fruits anywhere$/apples in the basket\noranges on the table\nmelons on the desk/" input.txt

정도면 되겠네요. 일단 제가 테스트해보니 잘 되는 듯 합니다.

좋은 하루 되세요!