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/bashdate +%d:%m >> dbdata.growthpsql -h 192.168.2.173 -U postgres -c select pg_database_size('ddb');   | sed -n    '3,3p' | numfmt --to=iec >>dbdata.growthpsql -h 192.168.2.173 -U postgres -c select pg_database_size('dpkidb');   | sed  -n '3,3p' | numfmt --to=iec >>dbdata.growthThe script produces the following output in the format as shown below 26:03         134G         4.4M26:03         134G         4.4MThe issue for me is that I want all the three columns in the same row. How can I achieve that?
Bash Scripting : Printing column data in the same row
bash;sed;scripting;echo
Replace all output lines, such as:date +%d:%m >> dbdata.growthwith lines such as:date +%d:%m | tr -d $'\n' >> dbdata.growthThis uses tr to delete newline characters before they are put in the output file.tr is a translate or delete utility.  In this case, the use of the -d option tells it to delete.  The character that we ask it to delete is the newline character, expressed as $'\n'.