Cheatography
https://cheatography.com
merging pages 4 and 5 of awk (english) Cheat Sheet
by TME520 to save space
This is a draft cheat sheet. It is a work in progress and is not finished yet.
I/O Statements (cont)
print expr-list >file |
Prints expressions on file. Each expression is separated by the value of the OFS variable. The output record is terminated with the value of the ORS variable. |
printf fmt, expr-list |
Format and print. |
printf fmt, expr-list >file |
Format and print on file. |
system(cmd-line) |
Execute the command cmd-line, and return the exit status. |
fflush([file]) |
Flush any buffers associated with the open output file or pipe file. If file is missing, then stdout is flushed. If file is the null string, then all open output files and pipes have their buffers flushed. |
print ... >> file |
Appends output to the file. |
print ... | command |
Writes on a pipe. |
print ... |& command |
Sends data to a co-process. |
Time Functions
systime() |
Returns the current time of day as the number of seconds since the Epoch (1970-01-01 00:00:00 UTC on POSIX systems). |
mktime(datespec) |
Turns datespec into a time stamp of the same form as returned by systime(). The datespec is a string of the form YYYY MM DD HH MM SS [DST]. |
strftime([format [, timestamp] ]) |
Formats timestamp according to the specification in format. The timestamp should be of the same form as returned by systime(). If timestamp is missing, the current time of day is used. If format is missing, a default format equivalent to the output of date(1) is used. |
|
|
GNU AWK’s Command Line Argument Summary
-F fs or --field-separator fs |
Use fs for the input field separator (the value of the FS predefined variable). |
-v var=val or --assign var=val |
Assign the value val to the variable var, before execution of the program begins. Such variable values are available to the BEGIN block of an AWK program. |
-f program-file or --file program-file |
Read the AWK program source from the file program-file, instead of from the first command line argument. Multiple -f (or --file) options may be used. |
-mf NNN or -mr NNN |
Set various memory limits to the value NNN. The f flag sets the maximum number of fields, and the r flag sets the maximum record size (ignored by gawk, since gawk has no pre-defined limits). |
-W compat or -W traditional or --compat--traditional |
Run in compatibility mode. In compatibility mode, gawk behaves identically to UNIX awk; none of the GNU-specific extensions are recognized. |
-W dump-variables[=file] or --dump-variables[=file] |
Print a sorted list of global variables, their types and final values to file. If no file is provided, gawk uses a file named awkvars.out in the current directory. |
-W help or -W usage or --help or --usage |
Print a relatively short summary of the available options on the standard output. |
|