删除文件shell脚本备份

2006年07月08日 | 200 次浏览 | 学习 | 1条评论  

这个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
然后把文件内容逐行读出的转化成本地路径,先备份打包,然后一起删除。

  1. #!/bin/bash
  2. #
  3. # use "sed" to change url to local path. separator is ";".
  4. #
  5. sed -e 's;http://www.mydomain.com/some_directory/;;g' url.txt >temp 
  6. #
  7. # loop. compress all files into a .tar file.
  8. #
  9. files=$(cat temp) 
  10. for file in $files 
  11. do 
  12.         tar -rf url_backup_`date +%Y%m%d%H`.tar  $file 
  13.         rm -rf $file 
  14.         echo $file 
  15. done 
  16. # end loop and delete the temporary file.
  17. rm -rf temp

评论

  1. niceidea

    2006年08年02日 8:52 pm

    什么鬼东西
    看不懂

Comment RSS TrackBack URI

相关推荐:

发表评论

更多文章

最受欢迎

评论最多