Categories
Linux Mastering Development

What does $0=$1 mean?

Let’s say, I have an input text file (sample_simple.txt) like this:

3 1 10 1 6
9 4 2  4 1
9 2 2  2 1

By using the command: awk '$0=$1" "$1*$2" "$3*$4' sample_simple.txt, I get the following output:

3 3 10
9 36 8
9 18 4

Then using the command: awk '$1*$2" "$3*$4' sample_simple.txt, nothing changes from the input file:

3 1 10 1 6
9 4 2  4 1
9 2 2  2 1

The only change between the commands is '$0=$1', Can anyone explain this?

Leave a Reply

Your email address will not be published. Required fields are marked *