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


提取文本中指定數字大小的行

cat 2222.txt  |grep play |grep -v textnr |sort |awk -F "-"  '$4 >50000 {print $0}'|  awk -F "-"  '$4 <60000 {print $0}'|uniq -w 31 -u |more

-w, --check-chars=N      //對每行第N 個字符以後的內容不作對照

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章