28 lines
969 B
Awk
Executable File
28 lines
969 B
Awk
Executable File
#!/usr/bin/awk -f
|
|
|
|
# https://www.grymoire.com/Unix/Awk.html
|
|
|
|
# built-in variables
|
|
# FS, OFS, NF, NR, RS, ORS, FILENAME
|
|
|
|
# barnett describes a number of other special variables, or environment
|
|
# variables as well:
|
|
# https://www.grymoire.com/Unix/Awk.html#toc-uh-55
|
|
|
|
# and even more predefined variables are listed and described in the
|
|
# gnu awk manual:
|
|
# https://www.gnu.org/software/gawk/manual/html_node/Built_002din-Variables.html#Built_002din-Variables
|
|
|
|
# example, the FILENAME variable. when reading data from a file (not
|
|
# from a pipe) FILENAME represents the name of the file providing input.
|
|
|
|
{ print FILENAME }
|
|
|
|
# must run script as './04.awk data.txt' not
|
|
# as cat data.txt ./04.awk'
|
|
|
|
# why is this useful? because awk can read from multiple files during one
|
|
# execution. you could run './04.awk data.txt data2.txt data3.txt', and
|
|
# the FILENAME variable will allow you to determine which file the script
|
|
# is processing at any given time during execution.
|