Topic: Text Processing with Awk/Sed/Grep
How to process awk '{print $2}' with jq so that it would be {"result": "value1,value2,..."}?

Topic: Text Processing with Awk/Sed/Grep
Rewrite this bash script to be more efficient #!/bin/bash

declare -a username_base
username_base=($(snmpwalk -v 2c -c $comm $host SNMPv2-SMI::enterprises.9.9.392.1.3.21.1.20 | grep STRING | awk -F"SNMPv2-SMI::enterprises.9.9.392.1.3.21.1.20." '{print $2}' | awk -F" " '{print $1}' | sed 's#[^.]*$##'))

count_username=${#username_base[@]}
echo "There are $count_username VPN users connected."
i=0
while [ ${i} -lt ${count_username} ]; do
username_oid=${username_base[$i]:0:-1}
username_dec=`echo $username_oid | sed 's/^[0-9]*.//' | sed 's/\./ /g'`
for x in `echo $username_dec`; do printf "\\$(printf %o "$x")"; done

vpn_agent=`snmpwalk -v 2c -c $comm $host SNMPv2-SMI::enterprises.9.9.392.1.3.21.1.18.${username_oid} | awk -F"STRING: " '{print $2}' | head -1`
vpn_extip=`snmpwalk -v 2c -c $comm $host SNMPv2-SMI::enterprises.9.9.392.1.3.21.1.10.${username_oid} | awk -F"STRING: " '{print $2}' | head -1`
vpn_intip=`snmpwalk -v 2c -c $comm $host SNMPv2-SMI::enterprises.9.9.392.1.3.21.1.8.${username_oid} | awk -F"STRING: " '{print $2}' | tail -1`
echo ", ${vpn_extip}, ${vpn_agent}, ${vpn_intip}"
i=$(($i+1))
done