Last active
June 13, 2018 15:55
-
-
Save cosysn/ec0cd7ac904f285d7d4f608c04ce01f5 to your computer and use it in GitHub Desktop.
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/sh | |
#line='id:2377893499379884 ip:127.0.0.1 port:443 ak:sdjh sk:jsdhfhjdsh bucket:men object:zzzz.vhd size:10240 encryp:1' | |
line=`cat image.cfg|grep 2377893499379884` | |
function map_get() | |
{ | |
dict=$1 | |
key=$2 | |
default_value=$3 | |
pair=`echo $dict | awk '{for(i=1;i<=NF;i++){print $i;}}' | grep "$key"` | |
realkey=`echo $pair|awk -F: '{print $1}'` | |
value=`echo $pair|awk -F: '{print $2}'` | |
if [ "$key"x != "$realkey"x ] || [ ""x == "$value"x ]; then | |
echo $default_value | |
return 0 | |
fi | |
echo $value | |
return 0 | |
} | |
value=`map_get "$line" "encryp" "abc"` | |
echo $value | |
value=`map_get "$line" "ip"` | |
echo $value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment