Quote:
Originally Posted by royalibrahim
But, what does 1 serve here or what is the role/purpose of 1?
Anyway, the default action of awk is to print the record right, even if the 'print' statement is missing?
|
Don't take everything for granted.
Code:
$ echo 'foo' | awk '/foo/' #default action
foo
$ echo 'foo' | awk '/foo/{print}' #defined action
foo
$ echo 'foo' | awk '/foo/{$1="bar"}' #defined action
$ echo 'foo' | awk '/foo/{print}1' #defined action and default action
foo
foo
$ echo 'foo' | awk '/foo/{$1="bar"}1'
bar