send the unix output to a csv file

后端 未结 5 856
野的像风
野的像风 2021-02-06 13:11

I want to put the output data from unix command to a csv file. Suppose the output which I am getting is :

A
B
C

I want to put this data in .csv

5条回答
  •  旧巷少年郎
    2021-02-06 13:22

    For my understanding, @Django needs three line into one line.

    paste -d ' ' - - - < infile
    

    If you need output as csv format (split by ,), you can use this

    paste -d ',' - - - < infile
    

    Here is the test result

    $ cat infile
    Manoj Mishra
    Japan
    Environment.
    Michael Jackson
    America
    Environment.
    
    $ paste -d ',' - - - < infile
    
    Manoj Mishra,Japan,Environment.
    Michael Jackson,America,Environment.
    

提交回复
热议问题