Add a header to a tab delimited file

前端 未结 8 850
北恋
北恋 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:51

    Customary awk answer.

    awk 'BEGIN { print "name\tage\tuniversity\tcity" } { print }' yourfile > /tmp/out && mv /tmp/out yourfile
    

提交回复
热议问题