更改AWK中的默认OFS,是否可能?

huangapple go评论44阅读模式
英文:

Changing the default OFS in AWK, is it possible?

问题

Is there a way to persistently change the default OFS in AWK from blank space to a tab? I find myself always having to specify the OFS when working with tab-delimited files, and I was wondering if those settings can be put in some sort of dotfile?

The closest I have seen is just to create an alias (alias awkt='awk -v OFS="\t"'), which I guess it does the job, but I still would like to know if AWK can be customized by providing some sort of dotfile.

英文:

Is there a way to persistently change the default OFS in AWK form blank space to a tab? I find myself always having to specify the OFS when working with tab delimited files and I was wondering if those settings can be put in some sort of dotfile?

The closest I have seen is just to create an alias ( alias awkt='awk -v OFS="\t"' ), which I guess it does the job, but I still would like to know if awk can be customized by providing some sort of dotfile.

答案1

得分: 1

所以简短的答案是“不”,因为AWK没有配置文件,所以你不能在AWK的配置中设置默认值。

你要么需要设置一个别名或函数来为你执行此操作,要么每次在命令行中设置它。

英文:

So the short answer is NO, since AWK does not have config files, so you cannot set a default "within" a config for AWK.

You will either have to setup an alias or a function to do this for you, or set it in the command line every time.

huangapple
  • 本文由 发表于 2023年3月21日 01:10:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/75793300.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定