英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论