Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create csv file using shell script

My output currently is:

echo "Time Taken to checkout svn repository repo_performance hosted on $host on `date` is : $Time_checkout seconds" >> log.csv
    echo "Time Taken to add $loopmax 10MB svn files in svn repository repo_performance  hosted on $host `date` is : $Time_add seconds" >> log.csv
    echo "Time Taken to commit $loopmax 10MB svn files in svn repository repo_performance  hosted on $host on `date` is : $Time_commit seconds" >> log.csv

But, I want to create a csv file which has Host, Date, Operation, Duration and its values in the rows.

How can I make it using scripting ?

like image 759
devops Avatar asked Oct 21 '16 11:10

devops


People also ask

How do I create a CSV file in Linux?

To create a CSV file with a text editor, first choose your favorite text editor, such as Notepad or vim, and open a new file. Then enter the text data you want the file to contain, separating each value with a comma and each row with a new line. Save this file with the extension . csv.

How do I create a custom CSV file?

Creating CSV File With ExcelAfter you create the spreadsheet, go to “File” and choose “Save As.” Click the drop-down menu labeled “Save as type” in the window that appears and choose “CSV (comma delimited)” from the list.


1 Answers

You may just do:

echo "$host, `date`, checkout,$Time_checkout" >> log.csv
echo "$host, `date`, add, $Time_add" >> log.csv
echo "$host, `date`, cimmit, $Time_commits" >> log.csv
like image 50
Hadrien Huvelle Avatar answered Oct 03 '22 03:10

Hadrien Huvelle