Portal Home > Knowledgebase > Articles Database > bash shell guru help - parse multiple arrays into csv format ?


bash shell guru help - parse multiple arrays into csv format ?




Posted by eva2000, 11-17-2011, 12:18 PM
When it comes to bash shell scripting still learning, but I'm currently stuck with trying to grab output results from script and reformatting the multiple arrays into CSV format. CSV format is so I can import the results into an Excel spreadsheet. I wrote a compression comparison bash shell script which can individually or collectively tests and compare the following gzipbzip2pigzpbzip2lbzip2lzipplzip sample output for pigz test run saved to filename.txt Not sure if it's correct way, but I grepped filename.txt to obtain 10 arrays full of info and the output of each array works running script produces 10 arrays each array on it's own line Where I am stuck is i need for the inform to formatted horizontally for each respective column of each array for *.csv file. Example of format desired: Taking the first column for each line of the 10 arrays listed above format for 1st line of *.csv file would be The second column for each line of 10 arrays listed, the format for 2nd line of *.csv file would be headings would be in csv format Any pointers or suggestions on how to do this solely via bash shell scripting ? thanks George

Posted by wartungsfenster, 11-17-2011, 12:50 PM
I might not be understanding what you need. echo "results[1]" | tr "\n" "," comes to mind.

Posted by eva2000, 11-17-2011, 02:55 PM
thanks for the tip looks like i was doing it wrong, if i change all 10 variables above and declare them as an array i can get my head around it using gives me what I want with output as



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
VolumeDrive Down (Views: 774)


Language: