记录字符串转header

2021-04-08  本文已影响0人  夜空最亮的9星

字符串如下:
mac_address=08%3A00%3AX7%3E5A%3AGB%3AE0&language=zh&device_brand=Android&type=readmore&uuid=11230&device_id=1900232321&smix=a&before_timestamp=01&show_moment=20&os_version=6.0.1&channel=xiaomi

t1.sh 文件内容如下:

input_str=$1

echo $input_str | sed 's/&/\n/g' | awk -F "=" '{print "'\''" $1 "'\''" ":" "'\''" $2 "'\''"  "," }'

执行 : sh t1.sh 'mac_address=08%3A00%3AX7%3E5A%3AGB%3AE0&language=zh&device_brand=Android&type=readmore&uuid=11230&device_id=1900232321&smix=a&before_timestamp=01&show_moment=20&os_version=6.0.1&channel=xiaomi'

'mac_address':'08%3A00%3AX7%3E5A%3AGB%3AE0',
'language':'zh',
'device_brand':'Android',
'type':'readmore',
'uuid':'11230',
'device_id':'1900232321',
'smix':'a',
'before_timestamp':'01',
'show_moment':'20',
'os_version':'6.0.1',
'channel':'xiaomi',
上一篇下一篇

猜你喜欢

热点阅读