IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    删除文件shell脚本备份

    潘魏增发表于 2006-07-08 14:43:24
    love 0

    这个shell脚本的用处是读出url.txt的内容,url.txt内容类似于

    http://www.mydomain.com/some_directory/1.html
    http://www.mydomain.com/some_directory/2.html
    http://www.mydomain.com/some_directory/3.html
    http://www.mydomain.com/some_directory/4.html

    然后把文件内容逐行读出的转化成本地路径,先备份打包,然后一起删除。

    #!/bin/bash 
    # 
    # use "sed" to change url to local path. separator is ";". 
    # 
    sed -e 's;http://www.mydomain.com/some_directory/;;g' url.txt >temp 
    #
    # loop. compress all files into a .tar file. 
    #
    files=$(cat temp) 
    for file in $files 
    do 
            tar -rf url_backup_`date +%Y%m%d%H`.tar  $file 
            rm -rf $file 
            echo $file 
    done 
    # end loop and delete the temporary file. 
    rm -rf temp


沪ICP备19023445号-2号
友情链接