錯誤一:
Hive的where后不能用字段的別名,
錯誤二:
hive的groupby中不能用自己定義函數,否則報錯(用嵌套select取代)
錯誤三:
運行:$ ./hive_game_operationstatis5.sh時,報錯信息例如以下:
./hive_game_operationstatis5.sh:line 11: [: missing `]' ./hive_game_operationstatis5.sh:line 17: /tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis120141014.txt:No such file or directory ./hive_game_operationstatis5.sh:line 36:/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis220141014.txt:No such file or directory ERROR 2 (HY000) atline 1: File'/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis120141014.txt'not found (Errcode: 2) ERROR 2 (HY000) atline 1: File'/tmp/statis_activitysourcestatis20141014/statis_activitysourcestatis220141014.txt'not found (Errcode: 2)
錯誤分析:
因為11行的創建文件夾代碼沒起作用,所以導致后邊一系列找不到文件路徑的錯誤。
報錯時的代碼:
if [ ! -d $output] then mkdir -p $output fi<span style="font-family: Arial, Helvetica, sans-serif;"> </span>
改動后的代碼:
if [ ! -d $output] then mkdir -p $output fi
看到區別了沒??$output與]之間應該有個空格!
。
錯誤四:date不能識別
運行./hive_game_operationstatis6.sh腳本時。報錯例如以下:
./hive_game_operationstatis6.sh:line 12: [: /tmp/statis_suspendedwindowstatisdate: binary operator expected ./hive_game_operationstatis6.sh:line 21: $output/$file_name1: ambiguous redirect ./hive_game_operationstatis6.sh:line 39: $output/$file_name2: ambiguous redirect ./hive_game_operationstatis6.sh:line 56: $output/$file_name3: ambiguous redirect ./hive_game_operationstatis6.sh:line 73: $output/$file_name4: ambiguous redirect ./hive_game_operationstatis6.sh:line 90: $output/$file_name5: ambiguous redirect
分析:
在shell腳本中我是這樣寫:
output='/tmp/statis_suspendedwindowstatis'$date file_name1='statis_suspendedwindowstatis1'$date'.txt'
錯誤顯示是指調用時”模糊的重定向”!
單從錯誤提示上看不出個所以然來。請直接看出錯代碼:
改動之前代碼:
date=’date +%Y%m%d’
改動此bug之后代碼:
date=`date +%Y%m%d`
大家看到哪里出錯了沒??哈哈,是的,太坑啦!
shell要用鍵盤上1前邊的‘撇’,而不能用雙引號那個‘撇’兒。
。
假設一個變量后是字符串的話直接用回車左邊那個’撇‘就能夠,
對於我這個初次接觸shell的人。簡直頭疼到了極點!
希望大家不要犯類似的錯誤。