What does the $0 variable refer to in awk?

In awk, the $0 variable refers to the entire current record or line of input. It contains all the text of the line being processed, including all fields.

For example, if you have a file with the following content:

Hello World
This is awk

Using awk like this:

awk '{ print $0 }' filename.txt

will output:

Hello World
This is awk

Summary

  • $0 represents the whole line of input in awk.
  • It is useful when you want to work with or display the entire record.

If you have further questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!