问题
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