Skip to content

Instantly share code, notes, and snippets.

@dm4
Created January 16, 2012 06:20
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/1619367 to your computer and use it in GitHub Desktop.
Save dm4/1619367 to your computer and use it in GitHub Desktop.
find pair
hput () {
eval hash"${1//[.-]/a}"='$2'
}
hget () {
eval echo '${hash'"${1//[.-]/a}"'#hash}'
}
for tmp in "$@"
do
tmp=`echo $tmp | cut -c 5-`
tmp=`echo $tmp | cut -d_ -f1`
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