首页 > 代码库 > sed
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。