Created
January 16, 2012 06:20
-
-
Save dm4/1619367 to your computer and use it in GitHub Desktop.
find pair
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
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