#!/bin/bash

echo "[" > TMPTAGS_1
ctags-universal \
   -R --output-format=json  -o TMPTAGS_2 \
   --extras=* --fields=* --kinds-c++=* \
   $1

cat TMPTAGS_2 | tr "\n" "," | sed -e "s/},{/},\n{/g" | tee -a TMPTAGS_1
rm TMPTAGS_2

head -n -1 TMPTAGS_1 > TAGS
tail -n 1 TMPTAGS_1 | rev | sed -e "s/,//" | rev | tee -a TAGS
rm TMPTAGS_1

echo -e "\n]" | tee -a TAGS
cat TAGS | tr "\n" " " | tee -a TAGS2