Top "Awk" questions

AWK is an interpreted programming language designed for text processing and typically used as a data extraction and reporting tool.

How can I format the output of a bash command in neat columns

I have a function which outputs many rows of information which I want to format in columns. The problem is …

bash awk zsh
What are NR and FNR and what does "NR==FNR" imply?

I am learning file comparison using awk. I found syntax like below, awk 'NR==FNR{a[$1];next}$1 in a{print $1}…

awk
Save modifications in place with awk

I am learning awk and I would like to know if there is an option to write changes to file, …

linux unix awk
How to use awk to print lines where a field matches a specific string?

I have: 1 LINUX param1 value1 2 LINUXparam2 value2 3 SOLARIS param3 value3 4 SOLARIS param4 value4 I need awk to print all lines …

sed awk
How to print the number of characters in each line of a text file

I would like to print the number of characters in each line of a text file using a unix command. …

shell unix sed awk
sed or awk: delete n lines following a pattern

How would I mix patterns and numeric ranges in sed (or any similar tool - awk for example)? What I …

unix sed awk
How to print all the columns after a particular number using awk?

On shell, I pipe to awk when I need a particular column. This prints column 9, for example: ... | awk '{print $9}…

shell awk
how to merge two files consistently line by line

I have two files (file1.txt & file2.txt ) , files are only examples . How to merge the two files , in …

linux perl sed awk ksh
How can I pass variables from awk to a shell command?

I am trying to run a shell command from within awk for each line of a file, and the shell …

shell awk parameter-passing
How can I get the length of an array in awk?

This command echo "hello world" | awk '{split($0, array, " ")} END{print length(array) }' does not work for me and …

awk