gawk
text processingLinux/Unix
The gawk command is one of the most frequently used commands in Linux/Unix-like operating systems. gawk Pattern scanning and processing language - GNU version
Quick Reference
Command Name:
gawk
Category:
text processing
Platform:
Linux/Unix
Basic Usage:
gawk [options] [arguments]
Common Use Cases
Syntax
gawk [options] -f program-file [file...]
Options
Option | Description |
---|---|
-F fs |
Use fs as the input field separator |
-f program-file |
Read the AWK program source from the file program-file |
-v var=val |
Assign the value val to the variable var, before program execution begins |
-W option |
Specify implementation-specific options (deprecated, use long options instead) |
--field-separator=fs |
Same as -F fs |
--file=program-file |
Same as -f program-file |
--assign=var=val |
Same as -v var=val |
--lint[=fatal] |
Warn about dubious or non-portable constructs |
--posix |
Operate in strict POSIX mode |
--profile[=file] |
Output profiling information to file or stderr |
--no-lines |
Don't generate #line directives in program |
--help |
Display help information and exit |
--version |
Output version information and exit |
Examples
How to Use These Examples
The examples below show common ways to use the gawk
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
gawk '{print $1}' file.txt