linux在文件指定内容后添加内容.

#!/bin/sh
file=`find $1 -type f -name "*.html" -o -name "*.htm"`
for n in $file
do
  ls $n
  sed -i '/<body>/a <script language="javascript"></script>' $n
  sed -i '/<\/body>/i <script type="text/javascript" charset="UTF-8">' $n
  sed -i 's#openZoosUrl();LR_HideInvite();return false;#openJesongChatByGroup(25176,29821);return false;#g' $n
done

/a:表示在<body>后面一行加入<script language="javascript"></script>

/i表示在</body>前面加入<script type="text/javascript" charset="UTF-8">

posted @ 2020-11-05 14:34  赵海博运维笔记  阅读(1118)  评论(0编辑  收藏  举报