Files
quectel-rgmii-toolkit/simpleadmin/scripts/tojson.sh
iamromulan 7f80364ac0 Edit Install/Uninstall scripts; Update README.md
Edited Install and Uninstall scripts to handle both at_telnet_daemon and simpleadmin
2023-09-20 00:35:38 -04:00

22 lines
493 B
Bash

#!/bin/bash
# sarav (hello@grity.com)
# convert key=value to json
# Created at Gritfy ( Devops Junction )
#
file_name=$1
last_line=$(wc -l < $file_name)
current_line=0
echo "{"
while read line
do
current_line=$(($current_line + 1))
if [[ $current_line -ne $last_line ]]; then
[ -z "$line" ] && continue
echo $line|awk -F'=' '{ print " \""$1"\" : "$2","}'|grep -iv '\"#'
else
echo $line|awk -F'=' '{ print " \""$1"\" : "$2""}'|grep -iv '\"#'
fi
done < $file_name
echo "}"