2013-11-26 60 views
6

我试图将数据从HBase Shell导出到我可以解析的文本文件,并添加到msysql数据库。从HBase shell导出数据

我目前使用下面的命令:

echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell > registration.txt 

其中出口一切从HBase的外壳到registration.txt。

我怎样才能去掉外壳的介绍,并总结,只是将数据追加到文本文件中的行:

如:壳牌进我想省略:

HBase Shell; enter 'help<RETURN>' for list of supported commands. 
Type "exit<RETURN>" to leave the HBase Shell 
Version 0.94.5-mapr, Wed May 1 7:42:07 PDT 2013 

总结我想省略:

ROW          COLUMN+CELL 
4419 row(s) in 12.9840 seconds 

回答

10

试试这个

echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell | grep "^ " > registration.txt 

由于结果与单一的空间前缀,剩下的东西就都被过滤掉。

+0

它的工作原理!直接在shell中运行。不在HBase shell提示符下 – Sakthivel

1

你可以一个步骤添加到您的管道跳过前4行包含所有不需要的东西,做到这一点:

$ echo "scan 'registration',{COLUMNS=>'registration:status'}" | hbase shell \ 
    | awk 'NR>5{print$0}' 
0

你也可以简单的事情有点通过利用这里串在Bash shell例如:

$ hbase shell <<< "scan 'registration',{COLUMNS=>'registration:status'}" \ 
    | grep "^ " > registration.txt