How to print $ 2 on awk only if the fourth field is not 0 (zero).
line="root 13246 11314 457 15: qsRw -m1"
then awk will print 13246, but if
line="root 13246 11314 0 15: qsRw -m1"
then awk doesn't print anything
awk '{if ($4) print $2;}' < inputfile
awk '$4!=0{print $2}' file
or simply
awk '$4{print $2}' file
The awk syntax is
awk '/pattern/{action}' file
the "template" part is actually an implicit if control. Therefore, you can omit the "if" keyword.
Source: https://habr.com/ru/post/1750661/More articles:MySql too many connections - javaI want to read email body and attachment with Windows Mobile - windows-mobile-6.5How can I connect directly to a mobile device via 3G? - mobileDoes the java agent work in a separate thread? - javaOn a web site running ASP.NET, how can I display an image saved in an MS Access 2007 application type - asp.netCruiseControl.net Design Does Not Start - cruisecontrol.nethttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1750663/alternatives-to-storing-moose-object-using-apachesession-with-code-references&usg=ALkJrhi91OVwaGLX0br7YlGEf3oE44wGsQJava: How to get around the lack of an equatable interface? - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1750665/user-must-have-accepted-tos-facebook-graph-api-error-when-posting-photos-to-group-page&usg=ALkJrhjk5H7aRuvjq8vPPaowyN7hGcMeWAAn open source open source software modem that runs on Linux? - c ++All Articles