且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在awk中修改文本文件

更新时间:2023-11-14 23:00:22

无需单独输出每列,只需修改现有数据,然后打印修改后的行即可.

There is no need to output every single column individually, it's enough to modify the existing data and then print the modified line.

awk -F '\t' '{ col4 = $4; $4 = col4 - 12; $5 = col4 + 50; print }' OFS='\t' file

这会在打印整行之前修改第四和第五个制表符分隔的列.

This modifies the fourth and fifth tab-delimited column before printing the whole line.