Add a header to a tab delimited file

前端 未结 8 843
北恋
北恋 2020-12-14 21:46

I\'d like to add a header to a tab-delimited file but I am not sure how to do it in one line in linux.

Let us say my file is:



        
8条回答
  •  春和景丽
    2020-12-14 22:48

    $ { printf 'name\tage\tuniversity\tcity\n'; cat orig-file; } > new-file
    

    Or

    $ printf '1\ni\nname\tage\tuniversity\tcity\n.\nw\n' | ed -s orig-file
    

提交回复
热议问题