Of course, but this is heavily depending on your input files. In your sample files, the server ID is far out right, with so many space before it, so don't expect it to come into the desired position by itself. As I said before, you could play around with FS and OFS variables to awk to improve the output formatting.
If you post two carefully composed input files, we can have a look onto the output formatting.
Then you have to play with FS and OFS, as mentioned before. Try like FS=" +" and OFS="\t" and combinations of white space that you see in your in your input files. BTW - your input files have trailing spaces that can influence results as well. Try to get rid of them.
Below im pasting the script which is running on 2 different servers and generating the files 348.csv & 349.csv (which we are trying to merge)
#!/bin/bash
F=eai_js_348.csv
D=dm_eai_348.csv
cat > $F << EOF # Write a header to the file $F
Timestamp BRM Servers
348
EOF
cat > $D << EOF # Write a header to the file $D
Timestamp BRM Servers
348
EOF
# Write data every 1800 seconds.
while sleep 1800; do
date +'%m/%d/%Y %H:%M' | tr -d \\n >> $F
printf ' ' >> $F
netstat | grep 16001 | wc -l >> $F
date +'%m/%d/%Y %H:%M' | tr -d \\n >> $D
printf ' ' >> $D
ps -ef | grep -i DM_EAI | wc -l >> $D
done
So, wanted to check if something can be fine tuned in this script only so that can avoid the formatting of the final output (after the merge) or atleast can get rid of the trailing spaces or any other formatting issues what you mentioned in the previous post.
I can't see anything immediately jumping to my eyes. There's no trailing spaces in above script...
You could try to print everything in one go to the respective files: