shenwei356 / csvtk

A cross-platform, efficient and practical CSV/TSV toolkit in Golang
http://bioinf.shenwei.me/csvtk
MIT License
999 stars 84 forks source link

add-header in place #224

Closed vkkodali closed 1 year ago

vkkodali commented 1 year ago

This may be more of a question than an issue... I often come across situations where I have to either add or modify a header and prefer to do it in place without having to write the output to a new file. Is this possible? If not, can this be added as an option to add-header, del-header, rename and rename2 commands?

shenwei356 commented 1 year ago

In-place file edit are not easily supported. https://unix.stackexchange.com/questions/11067/is-there-a-way-to-modify-a-file-in-place

A common way is writinf to a new file, renaming and overwriting the old one.

vkkodali commented 1 year ago

Thanks, writing to a temporary file and copying it over the new one is what I am doing now. I guess I will just stick to that.