Top "Awk" questions

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

Check field length using awk

I have a file of 3 fields: 123710337783,351898014413150,123028040249634 123710337785,352934028758390,123028040109275 I need to check that the fields meet the following lengths: Field 1 = 12 Field 2 = 15 or 16 …

awk field
Easiest way to extract the urls from an html page using sed or awk only

I want to extract the URL from within the anchor tags of an html file. This needs to be done …

html regex bash sed awk
Using AWK to Process Input from Multiple Files

Many people have been very helpful by posting the following solution for AWK'ing multiple input files at once: $ awk 'FNR==…

awk
Show filename and line number in grep output

I am trying to search my rails directory using grep. I am looking for a specific word and I want …

awk grep
how to use sed, awk, or gawk to print only what is matched?

I see lots of examples and man pages on how to do things like search-and-replace using sed, awk, or gawk. …

regex unix sed awk gawk
Using AWK to filter out column with numerical ranges

I'm relatively new to BASH and I'm trying to use awk to filter out column 1 data based on the 4th …

bash numbers awk range
Sort a text file by line length including spaces

I have a CSV file that looks like this AS2345,ASDF1232, Mr. Plain Example, 110 Binary ave.,Atlantis,RI,12345,(999)123-5555,1.56 AS2345,…

bash sorting text awk
Can we use shell variables in awk?

Can we use shell variables in AWK like $VAR instead of $1, $2? For example: UL=(AKHIL:AKHIL_NEW,SWATHI:SWATHI_NEW) …

awk
How to get first n characters of each line in unix data file

I am trying to get the first 22 characters from a unix data file.Here is my data looks as below. …

linux unix awk cut