对wget简单封装shell脚本

2014-11-24 11:27:36 · 作者: · 浏览: 4

作用: 抓取某个url数据内容保存到指定目录的指定文件中

mywget.sh

#!/bin/sh
url=$1
dir=$2
file=$3
/usr/bin/wget ${url} -O ${dir}${file}.bk -o /dev/null

echo ${dir}${file}
bytes=$(du -s ${dir}${file}.bk | awk '{print $1}')
if [ $bytes -ne 0 ];then
echo replace ${dir}${file}
cp -rf ${dir}${file}.bk ${dir}${file}
else
echo 'wget ${url} failed'
fi
exit