awk Commands

Complete awk commands reference — 48 commands across 2 categories. Quick reference cheat sheet for Linux, macOS & BSD.

Options (30)

ShortcutAction
awk -f program-fileRead the AWK program source from the file program-file, instead of from the first command
awk -F fsUse fs for the input field separator (the value of the FS predefined variable)
awk -v var=valAssign the value val to the variable var, before execution of the program begins
awk -bTreat all input data as single-byte characters
awk -cRun in compatibility mode
awk -CPrint the short version of the GNU copyright information message on the standard output
awk -d[file]Print a sorted list of global variables, their types and final values to file
awk -D[file]Enable debugging of AWK programs
awk -e program-textUse program-text as AWK program source code
awk -E fileSimilar to -f, however, this option is the last one processed
awk -gScan and parse the AWK program, and generate a GNU .pot (Portable Object Template) format
awk -hPrint a relatively short summary of the available options on the standard output
awk -i include-fileLoad an awk source library
awk -IPrint the internal byte code names as they are executed when running the program
awk -kEnable CSV special processing
awk -l libLoad a gawk extension from the shared library lib
awk -L [value]Provide warnings about constructs that are dubious or non- portable to other AWK implement
awk -MForce arbitrary precision arithmetic on numbers
awk -nRecognize octal and hexadecimal values in input data
awk -NForce gawk to use the locale's decimal point character when parsing input data
awk -o[file]Output a pretty printed version of the program to file
awk -OEnable gawk's default optimizations upon the internal representation of the program
awk -p[prof-file]Start a profiling session, and send the profiling data to prof-file
awk -PThis turns on compatibility mode, and disables a number of common extensions
awk -rEnable the use of interval expressions in regular expression matching
awk -sDisable gawk's default optimizations upon the internal representation of the program
awk -SRun gawk in sandbox mode, disabling the system() function, input redirection with getline
awk -tProvide warnings about constructs that are not portable to the original version of UNIX aw
awk -VPrint version information for this particular copy of gawk on the standard output
awk --Signal the end of options

Built-in Variables (18)

ShortcutAction
ARGVArray of command line arguments
BINMODEOn non-POSIX systems, specifies use of "binary" mode for all file I/O
CONVFMTThe conversion format for numbers, "%.6g", by default
ENVIRONAn array containing the values of the current environment
ERRNOIf a system error occurs either doing a redirection for getline, during a read for getline
FIELDWIDTHSA whitespace-separated list of field widths
FILENAMEThe name of the current input file
FPATA regular expression describing the contents of the fields in a record
FSThe input field separator, a space by default
FUNCTABAn array whose indices and corresponding values are the names of all the user-defined or e
IGNORECASEControls the case-sensitivity of all regular expression and string operations
LINTProvides dynamic control of the --lint option from within an AWK program
PRECThe working precision of arbitrary precision floating-point numbers, 53 by default
PROCINFOThe elements of this array provide access to information about the running AWK program
ROUNDMODEThe rounding mode to use for arbitrary precision arithmetic on numbers, by default "N" (IE
RTThe record terminator
RLENGTHThe length of the string matched by match(); -1 if no match
TEXTDOMAINThe text domain of the AWK program; used to find the localized translations for the progra
📄 View Printable Cheat Sheet — Download as PDF or print · 🧩 Combine with other tools

Related Shortcut Pages

sed Regex (Regular Expressions) Bash / Shell jq (JSON) Python tmux

Search 13,500+ shortcuts across 269 platforms

Explore All Platforms Practice Shortcuts
📜 Every shortcut on this page is taken from the official awk documentation — man7.org
🔧 Spotted an error or a missing shortcut? Suggest an edit on GitHub — every accepted fix goes live on this page, the API and the CLI.

🤖 Ask AI about awk shortcuts

Open your assistant with this page preloaded as the source — great for follow-up questions like "which of these work in other apps?"

ChatGPT Claude Perplexity Gemini Grok