I have written a bash script to calculate the size of a
PostgreSQL database and print the output along with the date when the script was executed in a text file. The script code is as follows:
#!/bin/bash date +"%d:%m" >> dbdata.growth psql -h 192.168.2.173 -U postgres -c "select pg_database_size('ddb'); " | sed -n '3,3p' | numfmt --to=iec >>dbdata.growth psql -h 192.168.2.173 -U postgres -c "select pg_database_size('dpkidb'); " | sed -n '3,3p' | numfmt --to=iec >>dbdata.growth
The script produces the following output in the format as shown below
26:03 134G 4.4M 26:03 134G 4.4M
The issue for me is that I want all the three columns in the same row. How can I achieve that?