I try to process the result of the command in a loop, but the result of that command is unexpected. Instead of a string, a numeric value is obtained. Any ideas why it's happening?
$ psql -qAtX -c 'select json_agg(r) from (select client_addr as "{#ADDR}",application_name as "{#NAME}",sync_state as "{#STATE}" from pg_stat_replication where usename<>'\''backup'\'') r' > /tmp/out.txt
$ cat /tmp/out.txt
[{"{#ADDR}":"192.168.0.100","{#NAME}":"test","{#STATE}":"async"}]
$ for i in $(< /tmp/out.txt); do echo $i;done
1