cat notxt
<-- empty file -->
cat sometxt
monkey goes to market
awk '{print "Hello World!"}' notxt
<--no ouput-->
awk 'BEGIN {print "Hello World!"} {print} END {print "Good bye!"}' notxt
Hello World!
Good bye!
awk 'BEGIN {print "Hello World!"} {print} END {print "Good bye!"}' sometxt
Hello World!
monkey goes to market
Good bye!
ex#1.
Since notxt is empty; awk doesn't iterate and no output is printed.
ex#2.
although notxt is empty; BEGIN and END statements are still executed and output produced for those commands.
No comments:
Post a Comment