title: Need to remove comma from the end of the array in shell output
body: <p>(I have created bash script which will extract server information from multiple Linux server by doing SSH. Able to get the json output for all the servers ( from server variable) but need to remove comma at the end of the array for the last server.</p>
  
  <p>I have created variables and provide below print command</p>
  
  <pre><code>printf '{"hostname":"%s","UPTIME":"%s","memtotal":"%s","memUsed":"%s","swaptotal":"%s","swapUsed":"%s","cpuUtilization":"%s","disksJson":"%s"},\n' "$HOST" "$UPTIME" "$memTotal" "$memUsed" "$swapTotal" "$swapUsed" "$cpuUtilization" "$disksJson"
  
  (#!/bin/bash
  serverlist='/home/user/test/server_list.txt'
  servers=`cat $serverlist`
  for server in $servers;
  do
  set -e
  # General OS props
  HOST=$server
  UPTIME=$(ssh user@${server} uptime | awk '{print $3" "$4}'| sed 's/\(.*\),/\1/')
  
  printf '{"hostname":"%s","UPTIME":"%s","memtotal":"%s","memUsed":"%s","swaptotal":"%s","swapUsed":"%s","cpuUtilization":"%s","disksJson":"%s"},\n' "$HOST" "$UPTIME" "$memTotal" "$memUsed" "$swapTotal" "$swapUsed" "$cpuUtilization" "$disksJson"
  </code></pre>
  
  <p>I am getting following json output . I need to keep comma after every server output however do not need comma at the end of the last server output</p>
  
  <pre><code>{"hostname":"XXXXXXXX","UPTIME":"24 days","memtotal":"8052704","memUsed":"64.16%","swaptotal":"4190200","swapUsed":"0.00%","cpuUtilization":"0.00%","disksJson":"{"total":"493G", "used":"2%", "mountPoint":"/VEM"},
  {"total":"80G", "used":"16%", "mountPoint":"/app_2"},
  {"total":"829M", "used":"11%", "mountPoint":"/home"},
  {"total":"1.9G", "used":"1%", "mountPoint":"/tmp"}"},
  
  {"hostname":"XXXXXXXX","UPTIME":"11 days","memtotal":"8052704","memUsed":"40.58%","swaptotal":"4190200","swapUsed":"0.00%","cpuUtilization":"0.00%","disksJson":"{"total":"493G", "used":"2%", "mountPoint":"/VEM"},
  {"total":"80G", "used":"16%", "mountPoint":"/app_2"},
  {"total":"829M", "used":"11%", "mountPoint":"/home"},
  {"total":"1.9G", "used":"1%", "mountPoint":"/tmp"}"}, ------- this comma needs to be removed))
  </code></pre>