destpath=‘/home/hadoop/soft/hadoop-2.0.0-cdh4.5.0/cdhlib/‘
jarpath=‘/home/hadoop/soft/hadoop-2.0.0-cdh4.5.0/share/hadoop/‘
search=‘jar‘
iterdir(){
cd $1
for p in `ls`; do
echo "$p" |grep -q "$search"
if [ $? -eq 0 ]
then
echo "file $p"
cp -rf $p "$destpath$p"
else
if [ -d "$p" ] && [ "$p" != "mapreduce1" ]; then
cd $p
basepath=$(cd `dirname $0`; pwd -P)
iterdir $basepath
cd ..
fi
fi
done
}
iterdir $jarpath
递归遍历目录拷贝cdh下的lib到一个目录,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/chengxin1982/p/3851043.html