What does $0=$1 mean in awk?

It's not really $0=$1; think of it more like

$0 = ($1" "$1*$2" "$3*$4)

So

$0=$1" "$1*$2" "$3*$4

assigns the result of string concatenation $1" "$1*$2" "$3*$4 to variable $0 and performs the default action {print $0}, whereas

 $1*$2" "$3*$4

concatenates the results of $1*$2 and $3*$4 (with a space " " between) and performs the default action {print $0} because the result is a non-empty string. The value of $0 is not modified.


in awk

  • $0 is whole line
  • line can be changed on the fly

thus

  • $1" "$1*$2" "$3*$4 create 3 fields $1 , $1*$2 and $3*$4
  • $0= the result is put to the line, and implictly printed (see edit).

Edit :

If you omit $0=, ouput line is not changed.

As Steeldriver pointed out, since search is positive, line is prinetd.