2015-04-08 38 views
0

我正在修改shell腳本,我對腳本不熟悉。Shell sript - 從Hive表格獲取數據到文本文件

我能夠將數據從配置單元表中提取出來並放入txt文件中,但數據從第一行開始,我已經預先輸入了列標題。

我怎樣才能得到數據加載到第二行?

temp_pull() 
{ 
hadoop fs -cat /user/hive/warehouse/test_database.db/$1/* >> $2 
} 

temp_pull hive_table sample_txt_file.txt 

例如.txt文件:

col1 col2 col3 

調用temp_pull後():

col1 col2 col3 hivedataRow1 hivedataRow1 hivedataRow1 
hivedataRow2 hivedataRow2 hivedataRow3 
+0

請問您可以提供'fetch'腳本的內容嗎? – amow

+0

剛剛添加命令..... –

+0

您使用的是哪個版本的'Hadoop'和'hive'? –

回答

0

嘗試。

temp_pull() 
    { 
    hadoop fs -cat /user/hive/warehouse/test_database.db/$1/* | tail -n +2 >> $2 
    } 

    temp_pull srclist sample_txt_file.txt 

其他解決方案。

temp_pull() 
{ 
    hive -e 'select * from '$1'' | tail -n +2 > $2 
    } 

    temp_pull stud_02 sample_txt_file1.txt 

根據您的需要進行調整。

+0

那麼,這仍然有我的標題的第一行上的第一行數據..... –

+0

嘗試用尾-n +3 –

+0

現在嘗試...... –