Chinaunix首页 | 论坛 | 博客
  • 博客访问: 210430
  • 博文数量: 145
  • 博客积分: 3000
  • 博客等级: 中校
  • 技术积分: 1720
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-14 18:42
文章分类

全部博文(145)

文章存档

2011年(1)

2009年(144)

我的朋友

分类: LINUX

2009-09-09 11:38:48

by tangke 2009-09-09

今天在测试豹哥的LFS的时候对于里面用到大量包下载的问题,写了一个脚本。

#!/bin/bash

rm -rf download_list
rm -rf successful_list
rm -rf unsuccessful_list

sed -n -e '/http:\/\/.*/p' -e '/ftp:\/\/.*/p' download_list_tmp> download_list
sed -i 's/    //g' download_list

all=`cat download_list`


for a in ${all}
do
    filename=`echo "${a}" | sed -e 's/.*\///g' `
    if test -e ${filename}
    then
        case $1 in
            "down")
                echo "the ${filename} file exists..";;
            "list")
#                echo "download file save in successful_list"
                echo "${a}" >> successful_list;;
            *) echo "Sorry, you must input a parameters";;
        esac

    else
        case $1 in
            "down")
                echo "start to download the file ${filename}"
                wget ${a};;
            "list")
#                echo "undownload file save in unsuccessful_list"
                echo "${a}" >>unsuccessful_list;;
            *) echo "Sorry, you must input a parameters";;
        esac
    fi
done





#!/bin/bash


#delete the all directory
all=`ls`

for directory in ${all}
do
    if test -d ${directory}
    then
        rm ${directory} -rf
    fi
done

file=`ls *.bz2 *.gz`

for a in ${file}
do
    echo "tar xf ${a} -C ./"
    tar xf ${a} -C ./
done

阅读(269) | 评论(0) | 转发(0) |
0

上一篇:shell: 注意事项

下一篇:commands: bc

给主人留下些什么吧!~~