BBS水木清华站∶精华区
发信人: scaner (wget.downloading), 信区: Linux
标 题: 一个小程序,为wget准备目录
发信站: BBS 水木清华站 (Sun Jun 21 15:50:32 1998)
wget的下载功能虽然强大,但对确定下载文件存放
路径好象很弱,不然选-nd -nH不要树结构,不然就是
随着下载源建个深深的路径,很不爽,所以写了个小程序
程序的主要功能是按要求建个符号连接.
----auto.ln.dir----
#!/bin/sh
if [ $# -lt "2" ] ; then
echo "Auto.create.dir src dest"
exit 1
fi
src_path=$1
dest_path=$2
set `echo "$dest_path" |sed -e "s/\// /g"`
if [ -z $1 ] ; then
echo "Src path invalid!"
exit 1
fi
while [ $2 ]
do
if [ -d $1 ] ; then
cd $1
elif [ -f $1 ] ; then
echo "File [$1] is exsiting!"
exit 1
else
mkdir $1
cd $1
fi
shift 1
done
if [ -f $1 ] ; then
echo "File [$1] is exsiting!"
elif [ -d $1 ] ; then
echo "Dir [$1] is exsting!"
else
ln -s $src_path $1
echo "ln $src_path -> $dest_path"
fi
----END-----
具体的用法是:假如我要将ftp://xxx.xxx.xxx.xxx/a/b/c/d/倒到 /mnt/pool/D上
就先
auto.ln.dir /mnt/pool/D a/b/c/d
这样就把/mnt/pool/D链到当前目录的a/b/c/d上
然后在当前目录下启动wget
wget -m -c -nH -b ftp://xxx.xxx.xxx.xxx/a/b/c/d/
这样就把东西直接保存到指定的/mnt/pool/D上,
不要再移动了。
--
用一般的方法去寻找一般的规律。
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.119.65.36]
BBS水木清华站∶精华区