码迷,mamicode.com
首页 > 其他好文 > 详细

sed

时间:2014-05-03 00:53:15      阅读:336      评论:0      收藏:0      [点我收藏+]

标签:sed

sed ‘s/^/\//g‘ 4  行首增加指定字符




提取网页中的播放地址:


#!/bin/bash
printf "enter your dir:"
read dir
echo "$dir is xx"
cd $dir
echo `pwd`
for file in `ls .`
  do
 if [ -d $file ]; then
        echo $file
        cd $file
        echo `pwd`
        tree `pwd` |grep play |sed ‘s/.* //g‘>11
        tree `pwd` |grep play |sed ‘s/.* //g‘|awk -F "-" ‘{print $2}‘ >22
        paste -d "/" 22 11 > 33
#       echo "hello"
         sed ‘s/play.html-/zzz/g‘ 33 |sed ‘s/.htm//g‘|sed ‘s/zzz/play.html?/g‘ > 44
        cat 44| sed ‘s#^#http://‘${dir}‘/‘${file}‘/#g‘ > list.txt
            cat list.txt >> /root/$dir.txt
  fi
 cd ..
  done

删除已处理的播放地址:

#!/bin/bash
printf "enter your dir:"
read dir
echo "$dir is xx"
cd $dir
echo `pwd`
for file in `ls .`
do
 if [ -d $file ]; then
        cd $file
        tree `pwd` |grep play |sed ‘s/.* //g‘|awk -F "-" ‘{print $2}‘|sed ‘s#^#/home/test/www.qqq.com/‘${file}‘/#g‘ > 1.txt
        for line in `cat 1.txt`
   do
         `/bin/rm -rf $line` > /root/del.txt
        echo "hello"
  done
        fi
 cd ..
done


循环批量替换目录下的文件:

find . -name index.htm|sed ‘s/\(.*\/\)\([0-9]\+\)\(.*\)\(index.htm\)\(.*\)/mv \1\2\3\4\5 \1\2\3play.html?\2-0-1/g‘|sh


本文出自 “hyf” 博客,请务必保留此出处http://hanyunfei.blog.51cto.com/6531994/1405182

sed,布布扣,bubuko.com

sed

标签:sed

原文地址:http://hanyunfei.blog.51cto.com/6531994/1405182

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!