awktutorial/10-misc-functions.awk

31 lines
879 B
Awk
Executable File

#!/usr/bin/awk -f
# https://www.grymoire.com/Unix/Awk.html
# the barnett awk guide lists a few other useful miscellaneous functions:
# system(), close(), systime(), and strftime()
# and the barnett guide demonstrates using getline to read from pipes,
# including looping through multiple lines of piped input from another
# command: https://www.grymoire.com/Unix/Awk.html#toc-uh-49
# system(command)
# ...run any arbitrary shell command, returning the exit code of
# whatever you ran.
# close() - used with getline when reading from pipes (see barnett)
# systime() - returns a timestamp as number of seconds since jan 1, 1970
# strftime(format_string, timestamp) - format date strings into
# human readable output
BEGIN {
now = systime()
print "The time is now " now "."
print "You might also know this as " strftime("%a %b %e %H:%M:%S %Z %Y" ,now)
}