Quote:
Originally Posted by matt007
I expect it to return all matching records into output_file...but it returns me a 0 for each line in "filename".
|
Do you want to print all lines matching the condition? You have to simply use an expression, not an action. That is, don't put the brackets (nor the BEGIN section) and for each line matching the condition, the default action (print $0) will be executed.
Code:
awk 'substr($0,1,2) == "HI"' filename >> output_file
The same can be accomplished using grep
Code:
grep ^HI filename >> output_file