Top "Awk" questions

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

How to remove blank lines from a Unix file

I need to remove all the blank lines from an input file and write into an output file. Here is …

unix awk blank-line
Replace whitespace with a comma in a text file in Linux

I need to edit a few text files (an output from sar) and convert them into CSV files. I need …

linux shell csv sed awk
cut or awk command to print first field of first row

I am trying print the first field of the first row of an output. Here is the case. I just …

linux bash unix awk
How to print last two columns using awk

All I want is the last two columns printed.

awk
Using sed, Insert a line above or below the pattern?

I need to edit a good number of files, by inserting a line or multiple lines either right below a …

scripting sed awk
awk without printing newline

I want the variable sum/NR to be printed side-by-side in each iteration. How do we avoid awk from printing …

scripting awk newline
Convert date formats in bash

I have a date in this format: "27 JUN 2011" and I want to convert it to 20110627 Is it possible to do …

linux bash date awk
Printing column separated by comma using Awk command line

I have a problem here. I have to print a column in a text file using awk. However, the columns …

csv awk
AWK: Access captured group from line pattern

If I have an awk command pattern { ... } and pattern uses a capturing group, how can I access the string so …

regex awk
How can I shuffle the lines of a text file on the Unix command line or in a shell script?

I want to shuffle the lines of a text file randomly and create a new file. The file may have …

shell random command-line awk shuffle