从awk输出中删除空白行 [英] Remove blank line from awk output
本文介绍了从awk输出中删除空白行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从awk输出中删除前导空格。当我使用此命令时,将显示前导空格。
I am trying to remove leading whitespace from awk output. When I use this command, a leading whitespace is displayed.
diff test1.txt test.txt | awk '{print $2}'
output:
asdfasdf.txt
test.txt
weqtwqe.txt
如何使用awk删除开头的空白?
How can I remove the leading whitespace using awk?
在此先感谢
推荐答案
如果要打印$ 2所在的行,则可以有条件地根据字段数进行打印
if you want to print the lines where $2 exists you can do it conditionally on number of fields
awk 'NF>1{print $2}'
会做。
这篇关于从awk输出中删除空白行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文