【发布时间】:2014-11-27 21:01:40
【问题描述】:
我在 bash 脚本中有一组命令,例如在 impala 中运行查询。
#! /bin/sh
RESULT=`impala-shell -q "select count(*) from testable"`
shell脚本的结果是。
Starting Impala Shell without Kerberos authentication
Connected to mycomp.cool-cluster.com:21000
Server version: impalad version 2.0.0-cdh5 RELEASE (build 12323323)
Query: select count(*) from enriched_call
Fetched 1 row(s) in 0.62s
+----------+ | count(*) | +----------+ | 234343 | +----------+
我只想从此输出中获取值,即 234343,并尝试使用正则表达式、拆分等在脚本中断言计数。
如果我尝试消除非数字值,则版本中的数字也会出现。我想用“|”分割并获取值234343
【问题讨论】: