What are other awk built-in variables?

awk has several built-in variables that provide useful information during the processing of input data. Here are some of the commonly used built-in variables:

  1. $0: Represents the entire current record (line).

  2. $1, $2, ..., $n: Represents the individual fields in the current record, where n is the field number. For example, $1 is the first field, $2 is the second field, and so on.

  3. NF: Stands for "Number of Fields" in the current record. It indicates how many fields are present in the current line.

  4. NR: The total number of records processed so far (across all input files).

  5. FNR: The number of records processed in the current input file.

  6. FS: The input field separator, which defines how awk splits input lines into fields. The default is whitespace.

  7. OFS: The output field separator, which defines how awk separates fields in the output. The default is a space.

  8. RS: The input record separator, which defines how awk splits input into records. The default is a newline.

  9. ORS: The output record separator, which defines how awk separates records in the output. The default is a newline.

  10. ARGC: The number of command-line arguments passed to the awk program.

  11. ARGV: An array containing the command-line arguments passed to the awk program.

These variables can be very useful for manipulating and processing text data effectively in awk.

0 Comments

no data
Be the first to share your comment!