使用bash将带有标头的.txt文件转换为.csv

时间:2016-11-03 09:13:43

标签: bash unix

我需要一个bash脚本来从.txt文件中获取值并将其放在.csv文件中,从下面的响应我需要两个值TestStep和Messages        除了我有太多.txt文件来自我需要选择这两个值的所有文件并将它放在一个.csv

var tempBuffer = new Buffer(response.body, 'iso-8859-1');
var iconv = new Iconv('ISO-8859-1', 'UTF-8');
var tempBuffer = iconv.convert(tempBuffer);

示例输出应该类似于csv文件:

TestStep消息

    Status: FAILED
    Time Taken: 913
    Size: 301
    Timestamp: Thu Aug 18 14:35:17 IST 2016
    TestStep: Enroll User to a Class without filling fields

    ----------------- Messages ------------------------------
    [Contains] Missing token [Learnerid is required] in Response
    [Contains 1] Missing token [Courseid is required] in Response
    [Contains 2] Missing token [Classid is required] in Response

    ----------------- Properties ------------------------------
    StatusCode: 200
    Method: GET
    HTTP Version: HTTP/1.1
    Endpoint: https://qa01.exphosted.com
    URL: https://qa01.exphosted.com/apis/ext/ExpertusOneAPI.php?userid=1&Display+Columns=id%2Cuserid%2Cstatus&returntype=xml&apiname=AddRosterAPI

0 个答案:

没有答案