On Mon, Dec 29, 2025 at 05:40:23PM +0100, Vincent Veyron wrote:
> > =$ bash z.sh
> > Rowcount = 1
> > Full output:
> >         days_ago        |          oldest_date          | cnt
> > ------------------------+-------------------------------+-----
> >  7 days 03:48:07.348247 | 2025-12-22 07:22:32.593814+01 | 212
> > (1 row)
> > 
> 
> IIUC, Ron wants the 212 number?
> 
> Maybe use the -t switch, and 'cut' :

Ah, that part I misunderstood.

Well, if there is only 1 row returned, always, then the simplest thing
would be to change

> row_count="$( tail -n1 <<< "${returned}" | cut -d "|" -f 3)"

to this:

row_count="$( awk 'NR==3 {print $NF}' <<< "${returned}" )"

format can stay the same, we don't need to psql -t, or -a, and it will
just work :)

Best regards,

depesz



Reply via email to