Created
May 3, 2012 18:07
-
-
Save bhavanki/2587739 to your computer and use it in GitHub Desktop.
Helper scripts for Hadoop and HBase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Extracts row IDs (keys) from HBase shell results | |
# Remove the header and footer lines | |
# Mark the first line of each row with # replacing the initial space | |
# Eliminate all but the first 26 characters in each line (COLUMN+CELL column) | |
# Eliminate blank lines | |
# Eliminate the first space in each line, but not marks | |
# Merge all results that span more than one line | |
# Eliminate the marks | |
# Eliminate trailing spaces | |
cat $1 | \ | |
sed '/^ROW/d' | \ | |
sed '/row(s) in/d' | \ | |
sed 's/^.\(.*column=.*\)$/#\1/g' | \ | |
sed 's/^\(.\{26\}\).*/\1/g' | \ | |
sed '/^[[:space:]]*$/d' | \ | |
sed 's/^ //g' | \ | |
awk 'BEGIN { lastline = "" } \ | |
{ if ( $0 ~ /^#/ ) { | |
if ( lastline != "") { | |
print lastline; | |
} | |
lastline = $0 | |
} else { | |
lastline = lastline $0 | |
} | |
} | |
END { print lastline }' | \ | |
sed 's/^#\(.*\)/\1/g' | \ | |
sed 's/[[:space:]]*$//' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Extracts column values from HBase shell results | |
# Eliminate the header and footer lines | |
# Eliminate first 27 characters in each line (ROW column) | |
# Eliminate blank lines | |
# Merge all results that span more than one line | |
# Eliminate trailing spaces | |
cat $1 | \ | |
sed '/^ROW/d' | \ | |
sed '/row(s) in/d' | \ | |
sed 's/^.\{27\}//g' | \ | |
sed '/^[[:space:]]*$/d' | \ | |
awk 'BEGIN { lastline = "" } \ | |
{ if ( $0 ~ /^column/ ) { | |
if ( lastline != "" ) { | |
print lastline; | |
} | |
lastline = $0 | |
} else { | |
lastline = lastline $0 | |
} | |
} | |
END { print lastline }' | \ | |
sed 's/[[:space:]]*$//' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Starts the HBash shell no matter where you are | |
# Supports an alternate "dev" config via "hbshell dev" | |
# Modify this for your environment | |
HBASE_HOME=/home/you/apps/hbase-0.90.3-cdh3u1 | |
if [[ $1 == "dev" ]]; then | |
shift | |
HBASE_CONF_DIR=${HBASE_HOME}/conf-dev ${HBASE_HOME}/bin/hbase shell "$@" | |
else | |
${HBASE_HOME}/bin/hbase shell "$@" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment