Remove blank line from awk output

不羁岁月 提交于 2020-01-06 08:28:10

问题


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

How can I remove the leading whitespace using awk?

Thanks in advance


回答1:


if you want to print the lines where $2 exists you can do it conditionally on number of fields

awk 'NF>1{print $2}'

will do.



来源:https://stackoverflow.com/questions/32789063/remove-blank-line-from-awk-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!