Category:AWK
This programming language may be used to instruct a computer to perform a task.
Execution method:  Interpreted 

See Also: 

If you know AWK, please write code for some of the tasks not implemented in AWK.
AWK is a small but powerful programming language that can process and convert text files. AWK is part of every Unixderived system.
Each AWK program consists of patternaction statements.
The program reads each input line, checks lines against patterns, and runs matching actions.
For programs that never read input lines, the entire program can be one BEGIN { ... }
block.
 List users who have /bin/ksh as a shell.
$ awk F: '$7 == "/bin/ksh" { print $1 }' /etc/passwd
AWK has only three types of variables: they are strings, floatingpoint numbers, and associative arrays (where every array index is a string). Conversion between strings and numbers is automatic. AWK also has regular expressions, which appear in many AWK programs. There are a few builtin functions, like cos() and sprintf().
 Find average line length.
$ awk '{ cnt += length($0) } END { print cnt / NR }' /etc/rc
The name "AWK" comes from the initials of Alfred Aho, Peter Weinberger and Brian Kernighan: they invented AWK during the 1970s. A few decades later, Kernighan continues to maintain the reference implementation of AWK.
Links[edit]
 awk(1) manual page, short and brief
 gawk GNU awk manual
 AWK in Wikipedia
 AWK Community Portal
OnlineExecution[edit]
 ideone.com  gawk, mawk (both are kept up to date)
Todo[edit]
Reports:Tasks_not_implemented_in_AWK
Subcategories
This category has the following 4 subcategories, out of 4 total.
Pages in category "AWK"
The following 679 pages are in this category, out of 679 total.
2
A
 A+B
 Abbreviations, automatic
 Abbreviations, easy
 ABC problem
 ABC words
 Abundant odd numbers
 Abundant, deficient and perfect number classifications
 Ackermann function
 Additive primes
 Air mass
 Align columns
 Aliquot sequence classifications
 Almost prime
 Alternade words
 Amicable pairs
 Anagrams
 Anagrams/Deranged anagrams
 Angle difference between two bearings
 Angles (geometric), normalization and conversion
 Antiprimes
 Append a record to the end of a text file
 Append numbers at same position in strings
 Apply a callback to an array
 Approximate equality
 Archimedean spiral
 Arithmeticgeometric mean
 Arithmetic/Complex
 Arithmetic/Integer
 Array concatenation
 Array length
 Arrays
 Assertions
 Associative array/Creation
 Associative array/Iteration
 Associative array/Merging
 Attractive numbers
 Audio alarm
 Averages/Arithmetic mean
 Averages/Mean angle
 Averages/Mean time of day
 Averages/Median
 Averages/Mode
 Averages/Pythagorean means
 Averages/Root mean square
 Averages/Simple moving average
B
C
 Caesar cipher
 Calculating the value of e
 Calendar
 Call a function
 Cantor set
 Carmichael 3 strong pseudoprimes
 Casesensitivity of identifiers
 Casting out nines
 Catalan numbers
 Catalan numbers/Pascal's triangle
 Change e letters to i in words
 Changeable words
 Character codes
 Check that file exists
 Cheryl's birthday
 Chinese remainder theorem
 Chinese zodiac
 Chowla numbers
 Circles of given radius through two points
 Circular primes
 Cistercian numerals
 Closestpair problem
 Code Golf: Code Golf
 Collect and sort square numbers in ascending order from three lists
 Collections
 Colour bars/Display
 Combinations
 Combinations with repetitions
 Comma quibbling
 Commandline arguments
 Comments
 Common list elements
 Common sorted list
 Compare a list of strings
 Compare length of two strings
 Compiler/code generator
 Compiler/lexical analyzer
 Compiler/Simple file inclusion pre processor
 Compiler/syntax analyzer
 Compiler/virtual machine interpreter
 Compound data type
 Concatenate two primes is also prime
 Conditional structures
 Convert seconds to compound duration
 Conway's Game of Life
 Coprimes
 Copy a string
 Copy stdin to stdout
 Count how many vowels and consonants occur in a string
 Count in factors
 Count in octal
 Count occurrences of a substring
 Count the coins
 Cousin primes
 Create a file
 Create a twodimensional array at runtime
 Create an HTML table
 CSV data manipulation
 CSV to HTML translation
 Cubic Special Primes
 Cumulative standard deviation
 Currency
 CUSIP
 Cyclops numbers
D
 Damm algorithm
 Date format
 Date manipulation
 Day of the week
 Day of the week of Christmas and New Year
 Days between dates
 Decision tables
 Deepcopy
 Delete a file
 Department numbers
 Determine if a string has all the same characters
 Determine if a string has all unique characters
 Determine if a string is collapsible
 Determine if a string is numeric
 Determine if a string is squeezable
 Determine sentence type
 Digit fifth powers
 Digital root
 Digital root/Multiplicative digital root
 Dinesman's multipledwelling problem
 Discordian date
 Dot product
 Draw a clock
 Draw a cuboid
 Draw a sphere
 Dutch national flag problem
 Dynamic variable names
E
 Eban numbers
 Emirp primes
 Empty directory
 Empty program
 Empty string
 Entropy
 Enumerations
 Environment variables
 Equilibrium index
 Erdősprimes
 Ethiopian multiplication
 EuclidMullin sequence
 Euler's sum of powers conjecture
 Evaluate binomial coefficients
 Even or odd
 Evolutionary algorithm
 Exactly three adjacent 3 in lists
 Execute a system command
 Execute Brain****
 Exponentiation operator
 Exponentiation order
 Exponentiation with infix operators in (or operating on) the base
 Extra primes
 Extract file extension
 Extreme floating point values
F
 Factorial
 Factorions
 Factors of an integer
 Farey sequence
 FASTA format
 Feigenbaum constant calculation
 Fibonacci nstep number sequences
 Fibonacci sequence
 File extension is in extensions list
 File input/output
 File modification time
 File size
 Filter
 Find adjacent primes which differ by a square integer
 Find common directory path
 Find first missing positive
 Find limit of recursion
 Find minimum number of coins that make a given value
 Find prime n such that reversed n is also prime
 Find prime numbers of the form n*n*n+2
 Find square difference
 Find squares n where n+1 is prime
 Find the intersection of two lines
 Find the last Sunday of each month
 Find the missing permutation
 Find words which contain the most consonants
 Find words which contains all the vowels
 Find words which contains more than 3 e vowels
 Find words whose first and last three letters are equal
 Find words with alternating vowels and consonants
 Five weekends
 Fixed length records
 FizzBuzz
 Flowcontrol structures
 Floyd's triangle
 Formatted numeric output
 Forward difference
 Four is magic
 Frobenius numbers
 Function definition
 Function frequency
 Fusc sequence
G
 Gamma function
 Gapful numbers
 General FizzBuzz
 Generate lower case ASCII alphabet
 Generate random numbers without repeating a value
 Generic swap
 Get system command output
 Getting the number of decimals
 Globally replace text in several files
 Gray code
 Greatest common divisor
 Greatest element of a list
 Greatest subsequential sum
 Greyscale bars/Display
 Guess the number
 Guess the number/With feedback
H
 Hailstone sequence
 Halt and catch fire
 Hamming numbers
 Happy numbers
 Harmonic series
 Harshad or Niven series
 Hash from two arrays
 Hash join
 Haversine formula
 Hello world/Graphical
 Hello world/Line printer
 Hello world/Newbie
 Hello world/Newline omission
 Hello world/Standard error
 Hello world/Text
 Hello world/Web server
 Here document
 Hex words
 Hickerson series of almost integers
 Hofstadter FigureFigure sequences
 Hofstadter Q sequence
 HofstadterConway $10,000 sequence
 Horizontal sundial calculations
 Horner's rule for polynomial evaluation
 Hostname
 Hourglass puzzle
 HTTP
 Humble numbers
I
 I before E except after C
 IBAN
 Identity matrix
 Idiomatically determine all the characters that can be used for symbols
 Idiomatically determine all the lowercase and uppercase letters
 Implicit type conversion
 Include a file
 Increasing gaps between consecutive Niven numbers
 Increment a numerical string
 Infinity
 Input loop
 Input/Output for lines of text
 Input/Output for pairs of numbers
 Integer comparison
 Integer sequence
 Interactive help
 Introspection
 ISBN13 check digit
 Iterated digits squaring
K
L
 Lah numbers
 Langton's ant
 Largest difference between adjacent primes
 Largest five adjacent number
 Largest int from concatenated ints
 Largest number divisible by its digits
 Largest palindrome product
 Largest prime factor
 Largest product in a grid
 Largest proper divisor of n
 Last Friday of each month
 Last list item
 Law of cosines  triples
 Leap year
 Least common multiple
 Left factorials
 Length of an arc between two angles
 Leonardo numbers
 Letter frequency
 Levenshtein distance
 Linux CPU utilization
 Literals/Floating point
 Literals/Integer
 Literals/String
 Logical operations
 Long literals, with continuations
 Long multiplication
 Long year
 Longest common prefix
 Longest common suffix
 Longest string challenge
 Lookandsay sequence
 Loop over multiple arrays simultaneously
 Loops/Break
 Loops/Continue
 Loops/Dowhile
 Loops/Downward for
 Loops/For
 Loops/For with a specified step
 Loops/Foreach
 Loops/Increment loop index within loop body
 Loops/Infinite
 Loops/N plus one half
 Loops/Nested
 Loops/While
 Loops/With multiple ranges
 Loops/Wrong ranges
 LucasLehmer test
 Luhn test of credit card numbers
M
 Mad Libs
 Magic 8ball
 Magic constant
 Magic squares of doubly even order
 Magic squares of odd order
 Magnanimous numbers
 Make a backup file
 Make directory path
 Mandelbrot set
 Map range
 Matrix multiplication
 Matrix transposition
 Maximum difference between adjacent elements of list
 Maximum triangle path sum
 Maze generation
 McNuggets problem
 Menu
 Merge and aggregate datasets
 Mersenne primes
 Metronome
 MianChowla sequence
 Middle three digits
 Minimum number of cells after, before, above and below NxN squares
 Minimum numbers of three lists
 Minimum primes
 Modular inverse
 Monte Carlo methods
 Monty Hall problem
 Morse code
 Motzkin numbers
 Multifactorial
 Multiplication tables
 Multisplit
 Munchausen numbers
 Munching squares
 Mutual recursion
 Möbius function
N
 N'th
 Nqueens problem
 Naming conventions
 Narcissistic decimal number
 Nautical bell
 Neighbour primes
 Next special primes
 Nice primes
 Nim game
 Nondecimal radices/Convert
 Nondecimal radices/Output
 Nth root
 Null object
 Number names
 Number reversal game
 Numbers divisible by their individual digits, but not by the product of their digits.
 Numbers in base 10 that are palindromic in bases 2, 4, and 16
 Numbers in base16 representation that cannot be written with decimal digits
 Numbers which binary and ternary digit sum are prime
 Numbers whose count of divisors is prime
 Numbers with equal rises and falls
 Numbers with prime digits whose sum is 13
 Numbers with same digit set in base 10 and base 16
 Numeric separator syntax
O
P
 Palindrome dates
 Palindrome detection
 Palindromic primes
 Palindromic primes in base 16
 Pancake numbers
 Pangram checker
 Parse commandline arguments
 Parsing/RPN to infix conversion
 Pascal's triangle
 Password generator
 Pathological floating point problems
 Perfect numbers
 Perfect totient numbers
 Permutation test
 Permutations
 Permutations with repetitions
 Pernicious numbers
 Phrase reversals
 Pick random element
 Pig the dice game
 Piprimes
 Population count
 Positive decimal integers with the digit 1 occurring exactly twice
 Power set
 Price fraction
 Primality by trial division
 Primality by Wilson's theorem
 Prime decomposition
 Prime numbers p which sum of prime numbers less or equal to p is prime
 Prime numbers which contain 123
 Prime triplets
 Prime words
 Primes which contain only one odd digit
 Primes whose first and last number is 3
 Primes whose sum of digits is 25
 Primes with digits in nondecreasing order
 Probabilistic choice
 Product of divisors
 Program name
 Program termination
 Proper divisors
 Pseudorandom numbers/Middlesquare method
 Pythagorean quadruples
 Pythagorean triples
R
 Ramsey's theorem
 Random number generator (included)
 Random numbers
 Range expansion
 Range extraction
 Ranking methods
 Read a configuration file
 Read a file line by line
 Read a specific line from a file
 Read entire file
 Real constants and functions
 Recaman's sequence
 Regular expressions
 Remove duplicate elements
 Remove lines from a file
 Remove vowels from a string
 Rename a file
 Repeat
 Repeat a string
 Reverse a string
 Reverse the order of lines in a text file while preserving the contents of each line
 Reverse words in a string
 Roman numerals/Decode
 Roman numerals/Encode
 Roots of unity
 Rosetta Code/Rank languages by popularity
 Rot13
 Roundrobin tournament schedule
 Runlength encoding
 RungeKutta method
S
 Safe and Sophie Germain primes
 Safe mode
 Safe primes and unsafe primes
 Sailors, coconuts and a monkey problem
 Scope/Function names and labels
 Search a list
 SEDOLs
 Selective file copy
 Self numbers
 Selfdescribing numbers
 Semiprime
 Semordnilap
 Sequence of nonsquares
 Sequence of primes by trial division
 Sequence: smallest number greater than previous term with exactly n divisors
 Sequence: smallest number with exactly n divisors
 Sexy primes
 SHA256
 Shell oneliner
 Shift list elements to left by 3
 Shortcircuit evaluation
 Show ASCII table
 Show the (decimal) value of a number of 1s appended with a 3, then squared
 Show the epoch
 Sierpinski carpet
 Sierpinski triangle
 Sieve of Eratosthenes
 Singlylinked list/Element definition
 Sleep
 Smallest power of 6 whose decimal expansion contains n
 Smallest square that begins with n
 Smarandache primedigital sequence
 Smith numbers
 Snake and Ladder
 Sockets
 Solve equations with substitution method
 Sort a list of object identifiers
 Sort an array of composite structures
 Sort an integer array
 Sort numbers lexicographically
 Sort stability
 Sort the letters of string in alphabetical order
 Sort using a custom comparator
 Sorting algorithms/Bogosort
 Sorting algorithms/Bubble sort
 Sorting algorithms/Cocktail sort
 Sorting algorithms/Comb sort
 Sorting algorithms/Gnome sort
 Sorting algorithms/Insertion sort
 Sorting algorithms/Quicksort
 Sorting algorithms/Selection sort
 Sorting algorithms/Shell sort
 Soundex
 Special characters
 Special neighbor primes
 Special pythagorean triplet
 Special variables
 Spinning rod animation/Text
 Spiral matrix
 Split a character string based on change of character
 Square but not cube
 Squarefree integers
 Stack
 Stairclimbing puzzle
 Start from a main routine
 Steady Squares
 Stemandleaf plot
 Strange numbers
 Strange plus numbers
 Strange unique prime triplets
 Stream merge
 String append
 String case
 String comparison
 String concatenation
 String interpolation (included)
 String length
 String matching
 String prepend
 Strip a set of characters from a string
 Strip block comments
 Strip comments from a string
 Strip control codes and extended characters from a string
 Strip whitespace from a string/Top and tail
 Strong and weak primes
 Subleq
 Substring
 Substring primes
 Substring/Top and tail
 Successive prime differences
 Sudoku
 Sum and product of an array
 Sum and product puzzle
 Sum digits of an integer
 Sum multiples of 3 and 5
 Sum of a series
 Sum of divisors
 Sum of elements below main diagonal of matrix
 Sum of first n cubes
 Sum of primes in odd positions is prime
 Sum of square and cube digits of an integer are primes
 Sum of squares
 Sum of the digits of n is substring of n
 Sum to 100
 Summarize primes
 Summation of primes
 Superpermutation minimisation
 Sylvester's sequence
 Symmetric difference
 System time
T
 Table creation
 Table creation/Postal addresses
 Take notes on the command line
 Tau function
 Tau number
 Taxicab numbers
 Teacup rim text
 Temperature conversion
 Terminal control/Clear the screen
 Terminal control/Display an extended character
 Terminal control/Inverse video
 Terminal control/Ringing the terminal bell
 Terminal control/Unicode output
 Test integerness
 Text between
 Text processing/1
 Text processing/2
 Text processing/Max licenses in use
 The Name Game
 The Twelve Days of Christmas
 ThueMorse
 Tictactoe
 Tokenize a string
 Top rank per group
 Totient function
 Towers of Hanoi
 Trabb Pardo–Knuth algorithm
 Tree traversal
 Trigonometric functions
 Triplet of three numbers
 Truncatable primes
 Truncate a file
 Twin primes
 Two identical strings
 Two sum
 Type detection