如何在linux shell脚本中获取hbase的所有表并对每个表进行操作?;

如何在linux shell脚本中获取hbase的所有表并对每个表进行操作?;,shell,hbase,Shell,Hbase,现在我可以用这段代码来做,但是有更好的方法吗 output=`echo "list" | hbase shell` output=`echo ${output} | cut -d'[' -f 2 | cut -d']' -f 1` IFS=',' read -ra tables <<< "$output" for tb in "${tables[@]}"; do echo "${tb}\n" done output=`echo“list”| hbase shell`

现在我可以用这段代码来做,但是有更好的方法吗

output=`echo "list" | hbase shell`
output=`echo ${output} | cut -d'[' -f 2 | cut -d']' -f 1`
IFS=',' read -ra  tables <<< "$output"
for tb in "${tables[@]}"; do
    echo "${tb}\n"
done
output=`echo“list”| hbase shell`
output=`echo${output}| cut-d'['-f2 | cut-d']'-f1`

如果s=',read-ra tables您可以将其简化一点,如下所示。这不涉及中间变量声明,希望对您有所帮助

echo 'list' | hbase shell | sed -e '1,/TABLE/d' -e '/seconds/,$d' |
while IFS='' read -r line || [[ -n "$line" ]]; do
    echo "$line"
done

您可以将其简化一点,如图所示。这不涉及中间变量声明,希望对您有所帮助

echo 'list' | hbase shell | sed -e '1,/TABLE/d' -e '/seconds/,$d' |
while IFS='' read -r line || [[ -n "$line" ]]; do
    echo "$line"
done

这到底是怎么回事?我认为解析输出并没有那么优雅,不知道是否有更好的方法来实现这一点。这到底是怎么回事?我认为解析输出并没有那么优雅,不知道是否有更好的方法来实现这一点。