AWK不打印分离器 [英] awk doesn't print separator
本文介绍了AWK不打印分离器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我跑这个awk程序:
awk -F: '{if($1=="waheed") {$2=1;print $0}}' /etc/passwd
和的输出是:
mysql 1 118 129 MySQL Server,,, /nonexistent /bin/false
没有:
分离器,如何使它打印线在这种情况下与分离?
注意:这件事发生在写作前pression后 $ 2 = 1
without the :
separator, how to make it print the line in this case with the separator?
note : this happened after writing the expression $2=1
.
推荐答案
在AWK输出由OFS(输出领域seperater)变量默认情况下,空间的内容分开。这可以被设置与-v OFS =:
In awk output is seperated by the contents of the OFS ( output field seperater ) variable a space by default. This can be set with -v OFS=':'
awk -F : -v OFS=':' '{ cmds}' file
这篇关于AWK不打印分离器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文