Skip to content

Instantly share code, notes, and snippets.

@dm4
Created January 15, 2012 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dm4/1616584 to your computer and use it in GitHub Desktop.
Save dm4/1616584 to your computer and use it in GitHub Desktop.
find pair
hput () {
eval hash"$1"='$2'
}
hget () {
eval echo '${hash'"$1"'#hash}'
}
for tmp in "$@"
do
if [ "`hget $tmp`" != "" ]
then
echo "found pair: $tmp, "`hget $tmp`
else
a=`echo $tmp | cut -d_ -f1`
b=`echo $tmp | cut -d_ -f2`
hput "${b}_${a}" "$tmp"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment