creating a .csv file in bash

Posted on 2009-04-22
Medium Priority
Last Modified: 2013-12-26
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.
Question by:jaysilverheels
  • 2
LVL 85

Expert Comment

ID: 24207821
echo `date; echo ";"; date`

Author Comment

ID: 24209192
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`
LVL 85

Accepted Solution

ozo earned 2000 total points
ID: 24212157
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 '
' ';'

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This Windows batch file is useful for organizing image files from a digital camera or other source, but can have many other uses.  It simply renames the file(s) to match their create date.  For example, if you took a picture today at 1:40pm and the …
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question