shell 內容
#!/bin/bash #1. 判斷參數個數 if [ $# -lt 1 ] then echo Not Enough Arguement! exit; fi 尚硅谷大數據技術之 Hadoop(入門) ————————————————————————————— 更多 Java –大數據 –前端 –python 人工智能資料下載,可百度訪問:尚硅谷官網 #2. 遍歷集羣所有機器 for host in hadoop102 hadoop103 hadoop104 do echo ==================== $host ==================== #3. 遍歷所有目錄,挨個發送 for file in $@ do #4. 判斷文件是否存在 if [ -e $file ] then #5. 獲取父目錄 pdir=$(cd -P $(dirname $file); pwd) #6. 獲取當前文件的名稱 fname=$(basename $file) ssh $host "mkdir -p $pdir" rsync -av $pdir/$fname $host:$pdir else echo $file does not exists! fi done done