Shell script for executing hbase commands - Deleting all hbase tables
This script will fetch all the tables from HBase and perform disable and drop operation on 1 table at a time.
#Creating a temp file to store the output of "list" command.echo "list" | hbase shell > tableListSummary.txt#fetch only the list of tables and store it in an another temp file.tail -1 tableListSummary.txt > tableList.txt#Separate tables by commas and iterate to perform disable and drop commands.cat tableList.txt | sed -n 1'p' | tr ',' '\n' | while read word; do com=$(echo "$word" | sed 's/[][]//g') table="${com#\"}" table="${table%\"}" echo $table echo "disable '$table'" | hbase shell echo "drop '$table'" | hbase shelldone#removing temporary filesrm tableListSummary.txt tableList.txt
Thanks.