dm4
1/15/2012 - 5:55 PM

find pair

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