Category:AWK
This programming language may be used to instruct a computer to perform a task.
Execution method: | Interpreted |
---|---|
See Also: |
|
AWK is a small but powerful programming language that can process and convert text files. AWK is part of every Unix-derived system.
Each AWK program consists of pattern-action 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.<lang awk>$ awk -F: '$7 == "/bin/ksh" { print $1 }' /etc/passwd</lang>
AWK has only three types of variables: they are strings, floating-point 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 built-in functions, like cos() and sprintf().
- Find average line length.<lang awk>$ awk '{ cnt += length($0) } END { print cnt / NR }' /etc/rc</lang>
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
- awk(1) manual page, short and brief
- gawk GNU awk manual
- AWK in Wikipedia
- AWK Community Portal
Online-Execution
- ideone.com - gawk, mawk (both are kept up to date)
Todo
Subcategories
This category has the following 4 subcategories, out of 4 total.
@
- AWK Implementations (8 P)
- AWK User (69 P)
- Awk User (2 P)
Pages in category "AWK"
The following 200 pages are in this category, out of 709 total.
(previous page) (next page)F
- 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
- First 9 prime Fibonacci number
- Five weekends
- Fixed length records
- FizzBuzz
- Flow-control structures
- Floyd's triangle
- Formatted numeric output
- Forward difference
- Four is magic
- Four sides of square
- 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 decimal places
- Giuga numbers
- Globally replace text in several files
- Goldbach's comet
- 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 Figure-Figure sequences
- Hofstadter Q sequence
- Hofstadter-Conway $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
- Look-and-say sequence
- Loop over multiple arrays simultaneously
- Loops/Break
- Loops/Continue
- Loops/Do-while
- 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
- Lucas-Lehmer test
- Luhn test of credit card numbers
- LZW compression
M
- Mad Libs
- Magic 8-ball
- Magic constant
- Magic numbers
- 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
- Matrix with two diagonals
- Maximum difference between adjacent elements of list
- Maximum triangle path sum
- Maze generation
- McNuggets problem
- Menu
- Merge and aggregate datasets
- Mersenne primes
- Metronome
- Mian-Chowla sequence
- Middle three digits
- Minimum multiple of m where digital sum equals m
- 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
- Mosaic matrix