删除文件shell脚本备份

2006年07月08日 | 3,453 次浏览 | 标签: | 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

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

#!/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

相关文章

评论(1)

  1. niceidea 发表于2006年08月02日 8:52 pm

    什么鬼东西
    看不懂

发表评论

最受欢迎

评论最多