creating a .csv file in bash

Hi Guys,

I have a bash script that ssh onto many machines and changes to the root user to collect information from the machine. I collect the same information from each machine and then output it to the same file for each host. The problem is the formatting though. I want to be able to save the output such that I can open the file in excel.  I want the file to have the results of command 1 from each server in one column and all the results of command 2 in a column.

I tried to do a simple test on the command line settings IFS=';'' command 1; command2 but it prints the results of command 1 and command 2 on separate lines.

I hope you can help.
jaysilverheelsAsked:
Who is Participating?
 
ozoCommented:
if you want all 10 top entries to be separated by ; it may be easier to do
(host | awk -F '.' '{print $1}' ; df -h; ps -aux | grep [j]ava ; top | head -10) | tr '
' ';'
0
 
ozoCommented:
echo `date; echo ";"; date`
0
 
jaysilverheelsAuthor Commented:
Thank you Ozo for such a quick reply and helping with my other questions in the past.

From what you tell me would be following work

echo `host | awk -F '.' {print $1}; echo "," ; df -h; echo "," ; ps -aux | grep java; echo "," ; top | head -10`
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.