awk Flags & Options
Pattern scanning and text processing language.All awk pages
- awk -F (field separator): split on commas, colons, tabs or a regexawk -F sets the input field separator: -F, for CSV, -F: for /etc/passwd, -F'|' for pipes, or a regex such as -F'[,;]'. Setting FS in BEGIN does the same.
- awk -f script.awk: run an awk program from a fileawk -f script.awk reads the program from a file. Repeat -f to add function libraries, mix with gawk -e, or start the file with #!/usr/bin/awk -f to run it.
- awk -v var=value: pass a shell variable into an awk programawk -v name="$var" copies a shell value into an awk variable before BEGIN runs. Escapes in the value are processed; use ENVIRON for paths and raw text.
- gawk -i inplace: edit a file in place with awkgawk -i inplace rewrites each input file with the program's output, like sed -i. inplace::suffix keeps a backup; lines you do not print are lost from the file.