基于sed 的猫狗游戏

 

1.测试文件

[root@L shells]# cat catDog.txt 
snake
snake
pig
bird
dog
cat 
snake  
pig
bird
snake
cat
bird
dog 
bird
tiger
snake
bird
cat
lion
ji
sdf
View Code

2.sed脚本文件

[root@L shells]# cat sed.txt
/cat/,/dog/s/$/<---/

3.测试效果

[root@L shells]# sed -f sed.txt < catDog.txt 
snake
snake
pig
bird
dog
cat <---
snake  <---
pig<---
bird<---
snake<---
cat<---
bird<---
dog <---
bird
tiger
snake
bird
cat<---
lion<---
ji<---
sdf<---
View Code

 

posted @ 2018-12-16 12:54  Ray_chen  阅读(251)  评论(0编辑  收藏  举报