How to get all tables of hbase in linux shell script and operate on each table?

Multi tool use
How to get all tables of hbase in linux shell script and operate on each table?
Now I can do it with this code, but is there a better way to do this?
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
I thought it is not that graceful to parse the output and wonder if there is a better way to do this.
– xunyl
Jul 1 at 4:15
1 Answer
1
You could simplify that a bit more as shown here. This involves no intermediate variable declaration, hope it helps you.
echo 'list' | hbase shell | sed -e '1,/TABLE/d' -e '/seconds/,$d' |
while IFS='' read -r line || [[ -n "$line" ]]; do
echo "$line"
done
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What exactly is wrong with this?
– cricket_007
Jul 1 at 4:10