creating a .csv file in bash

Posted on 2009-04-22
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
    LVL 84

    Expert Comment

    echo `date; echo ";"; date`

    Author Comment

    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 84

    Accepted Solution

    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

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    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 …
    Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
    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 this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now