Convert .txt file to .csv with header in bash

后端 未结 3 2017
花落未央
花落未央 2020-12-20 10:08

.txt looks like:

2013-04-10;248179;5431;5375.30€;1.49
..
..
..

I need a .csv file with a Header:

Date       Visit   Login           


        
3条回答
  •  萌比男神i
    2020-12-20 10:43

    This should do it, if your fields don't contain any funny business:

    (echo "Date;Visit;Login;Euro;Rate" ; cat file.txt) | sed 's/;//g' > file.csv
    

    You'll just have to type a tab literally in bash (^V TAB). If your version of sed supports it, you can write\t instead of a literal tab.

提交回复
热议问题