If you have nawk, use it instead of awk because on some systems awk is very old and lacks many useful features. For an introduction to Awk, see faq271-5564.
Let me know whether or not this helps.
An awk program consists of test [tt]{[/tt] actions [tt]}[/tt] pairs. The actions are performed if the test succeeds for the line just read. When the test is of the form test1[tt],[/tt]test2 , it means "start performing the actions when test1 is true and continue until test2 is true". So we're telling Awk to start printing the line read ($0) when field 1 ($1) exists (i.e., when it's not an empty string) and to stop printing when [tt]0[/tt] is true. Well, 0 is always considered false, so Awk never stops printing; it prints the rest of the file.
Good point. If the $1 of first non-blank line is "0", $1 is treated as a number, not a string, so it will be considered false and the line won't be printed.
Your version will work in all cases (I think).
An illustration of the truism "Never trust a program that hasn't been thoroughly tested.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.