shell学习之检测批量下载成功与否

下载了很多源码包,我想看哪个下载成功了,哪个没下载成功。

wget http://blog.s135.com/soft/linux/nginx_php/nginx/nginx-0.8.46.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/php/php-5.2.14.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/phpfpm/php-5.2.14-fpm-0.5.14.diff.gz
wget http://blog.s135.com/soft/linux/nginx_php/mysql/mysql-5.5.3-m3.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/libiconv/libiconv-1.13.1.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/libmcrypt-2.5.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/mcrypt/mcrypt-2.6.8.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/memcache/memcache-2.2.5.tgz
wget http://blog.s135.com/soft/linux/nginx_php/mhash/mhash-0.9.9.9.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/pcre/pcre-8.10.tar.gz
wget http://blog.s135.com/soft/linux/nginx_php/eaccelerator/eaccelerator-0.9.6.1.tar.bz2
wget http://blog.s135.com/soft/linux/nginx_php/pdo/PDO_MYSQL-1.0.2.tgz
wget http://blog.s135.com/soft/linux/nginx_php/imagick/ImageMagick.tar.gz
wget http://pecl.php.net/get/imagick-2.3.0.tgz


这么多的包,下载的话很长时间。所以,就写了一个脚本来看看是否所有的都下载下来了。

我将上面的链接处理了下,把所有下载下来的压缩包名存在一个文件里

[root@Jason64-18 tools]# cat ~/wget.sh.txt
nginx-0.8.46.tar.gz
php-5.2.14.tar.gz
php-5.2.14-fpm-0.5.14.diff.gz
mysql-5.5.3-m3.tar.gz
libiconv-1.13.1.tar.gz
libmcrypt-2.5.8.tar.gz
mcrypt-2.6.8.tar.gz
memcache-2.2.5.tgz
mhash-0.9.9.9.tar.gz
pcre-8.10.tar.gz
eaccelerator-0.9.6.1.tar.bz2
PDO_MYSQL-1.0.2.tgz
ImageMagick.tar.gz
imagick-2.3.0.tgz

-----

[root@Jason64-18 tools]# pwd
/data/tools
[root@Jason64-18 tools]# ls
eaccelerator-0.9.6.1.tar.bz2  mcrypt-2.6.8.tar.gz    pcre-8.10.tar.gz
ImageMagick.tar.gz            memcache-2.2.5.tgz     PDO_MYSQL-1.0.2.tgz
imagick-2.3.0.tgz             mhash-0.9.9.9.tar.gz   php-5.2.14-fpm-0.5.14.diff.gz
libiconv-1.13.1.tar.gz        mysql-5.5.3-m3.tar.gz  php-5.2.14.tar.gz
libmcrypt-2.5.8.tar.gz        nginx-0.8.46.tar.gz
[root@Jason64-18 tools]# cat /server/scripts/duibi.sh
#!/bin/bash
#program
#this program shows which tar success download and  which not
. /etc/init.d/functions
file1=~/wget.sh.txt
A=`cat $file1`
for i in $A
do
  if [ -e $i ]
  then
     action "$i" /bin/true
  else
     action "$i" /bin/false
  fi
done

没下载的将会被显示为[FALSE]

[root@Jason64-18 tools]# sh /server/scripts/duibi.sh
nginx-0.8.46.tar.gz                                        [  OK  ]
php-5.2.14.tar.gz                                          [  OK  ]
php-5.2.14-fpm-0.5.14.diff.gz                              [  OK  ]
mysql-5.5.3-m3.tar.gz                                      [  OK  ]
libiconv-1.13.1.tar.gz                                     [  OK  ]
libmcrypt-2.5.8.tar.gz                                     [  OK  ]
mcrypt-2.6.8.tar.gz                                        [  OK  ]
memcache-2.2.5.tgz                                         [  OK  ]
mhash-0.9.9.9.tar.gz                                       [FAILED]
pcre-8.10.tar.gz                                           [FAILED]
eaccelerator-0.9.6.1.tar.bz2                               [  OK  ]
PDO_MYSQL-1.0.2.tgz                                        [  OK  ]
ImageMagick.tar.gz                                         [  OK  ]
imagick-2.3.0.tgz                                          [  OK  ]

全部都下载成功了就全部[OK]

[root@Jason64-18 tools]# sh /server/scripts/duibi.sh
nginx-0.8.46.tar.gz                                        [  OK  ]
php-5.2.14.tar.gz                                          [  OK  ]
php-5.2.14-fpm-0.5.14.diff.gz                              [  OK  ]
mysql-5.5.3-m3.tar.gz                                      [  OK  ]
libiconv-1.13.1.tar.gz                                     [  OK  ]
libmcrypt-2.5.8.tar.gz                                     [  OK  ]
mcrypt-2.6.8.tar.gz                                        [  OK  ]
memcache-2.2.5.tgz                                         [  OK  ]
mhash-0.9.9.9.tar.gz                                       [  OK  ]
pcre-8.10.tar.gz                                           [  OK  ]
eaccelerator-0.9.6.1.tar.bz2                               [  OK  ]
PDO_MYSQL-1.0.2.tgz                                        [  OK  ]
ImageMagick.tar.gz                                         [  OK  ]
imagick-2.3.0.tgz                                          [  OK  ]


以此记录自己以后每次的shell程序...

加油!gogogogogogogogo!

你可能感兴趣的:(shell,文件,检测,批量)