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 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.
$ awk -F: '$7 == "/bin/ksh" { print $1 }' /etc/passwd
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.
$ 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
Online-Execution[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 551 pages are in this category, out of 551 total.
A
- A+B
- Abbreviations, automatic
- Abbreviations, easy
- ABC problem
- ABC words
- Abundant odd numbers
- Abundant, deficient and perfect number classifications
- Ackermann function
- 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
- Anti-primes
- Append a record to the end of a text file
- Apply a callback to an array
- Approximate equality
- Archimedean spiral
- Arithmetic-geometric mean
- 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
- Case-sensitivity of identifiers
- Casting out nines
- Catalan numbers
- Catalan numbers/Pascal's triangle
- Changeable words
- Character codes
- Check that file exists
- Chinese remainder theorem
- Chinese zodiac
- Chowla numbers
- Circles of given radius through two points
- Circular primes
- Cistercian numerals
- Closest-pair problem
- Collections
- Colour bars/Display
- Combinations
- Combinations with repetitions
- Comma quibbling
- Command-line arguments
- Comments
- Compare a list of strings
- Compiler/code generator
- Compiler/lexical analyzer
- Compiler/syntax analyzer
- Compiler/virtual machine interpreter
- Compound data type
- Conditional structures
- Convert seconds to compound duration
- Conway's Game of Life
- Copy a string
- Copy stdin to stdout
- Count in factors
- Count in octal
- Count occurrences of a substring
- Count the coins
- Create a file
- Create a two-dimensional array at runtime
- Create an HTML table
- CSV data manipulation
- CSV to HTML translation
- Cumulative standard deviation
- Currency
- CUSIP
D
- Damm algorithm
- Date format
- Date manipulation
- Day of the week
- Days between dates
- Decision tables
- 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
- Digital root
- Digital root/Multiplicative digital root
- Dinesman's multiple-dwelling 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
- Ethiopian multiplication
- Euler's sum of powers conjecture
- Evaluate binomial coefficients
- Even or odd
- Evolutionary algorithm
- Execute a system command
- Execute Brain****
- Exponentiation operator
- Exponentiation order
- Extra primes
- Extract file extension
- Extreme floating point values
F
- Factorial
- Factorions
- Factors of an integer
- Farey sequence
- FASTA format
- Feigenbaum constant calculation
- Fibonacci n-step number sequences
- Fibonacci sequence
- File extension is in extensions list
- File input/output
- File modification time
- File size
- Filter
- Find common directory path
- Find limit of recursion
- Find the intersection of two lines
- Find the last Sunday of each month
- Find the missing permutation
- Find words which odd letters are consonants and even letters are vowels or vice versa
- Five weekends
- Fixed length records
- FizzBuzz
- Flow-control structures
- Floyd's triangle
- Formatted numeric output
- Forward difference
- Four is magic
- Function definition
- Function frequency
- Fusc sequence
G
- Gamma function
- Gapful numbers
- General FizzBuzz
- Generate lower case ASCII alphabet
- 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
- Hamming numbers
- Happy numbers
- 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
- 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
- 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
- Interactive programming
- Introspection
- ISBN13 check digit
- Iterated digits squaring
K
L
- Lah numbers
- Langton's ant
- Largest int from concatenated ints
- Largest number divisible by its digits
- Last Friday of each month
- 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 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/Wrong ranges
- Lucas-Lehmer test
- Luhn test of credit card numbers
M
- Mad Libs
- Magic 8-ball
- 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 triangle path sum
- Maze generation
- McNuggets problem
- Menu
- Mersenne primes
- Metronome
- Mian-Chowla sequence
- Middle three digits
- Modular inverse
- Monte Carlo methods
- Monty Hall problem
- Morse code
- Multifactorial
- Multiplication tables
- Multisplit
- Munchausen numbers
- Munching squares
- Mutual recursion
- Möbius function
N
O
P
- Palindrome dates
- Palindrome detection
- Pancake numbers
- Pangram checker
- Parse command-line arguments
- Parsing/RPN to infix conversion
- Pascal's triangle
- Password generator
- Pathological floating point problems
- Perfect numbers
- Perfect totient numbers
- Permutation test
- Permutations
- Pernicious numbers
- Phrase reversals
- Pick random element
- Population count
- Power set
- Price fraction
- Primality by trial division
- Prime decomposition
- Prime words
- Probabilistic choice
- Product of divisors
- Program name
- Program termination
- Proper divisors
- 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 words in a string
- Roman numerals/Decode
- Roman numerals/Encode
- Roots of unity
- Rosetta Code/Rank languages by popularity
- Rot-13
- Run-length encoding
- Runge-Kutta method
S
- Safe mode
- Sailors, coconuts and a monkey problem
- Scope/Function names and labels
- Search a list
- SEDOLs
- Selective file copy
- Self numbers
- Self-describing numbers
- Semiprime
- Semordnilap
- Sequence of non-squares
- 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
- SHA-256
- Shell one-liner
- Short-circuit evaluation
- Show ASCII table
- Show the epoch
- Sierpinski carpet
- Sierpinski triangle
- Sieve of Eratosthenes
- Singly-linked list/Element definition
- Sleep
- Smarandache prime-digital sequence
- Smith numbers
- Sockets
- Sort a list of object identifiers
- Sort an array of composite structures
- Sort an integer array
- Sort numbers lexicographically
- Sort stability
- 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 variables
- Spinning rod animation/Text
- Spiral matrix
- Split a character string based on change of character
- Square but not cube
- Square-free integers
- Stair-climbing puzzle
- Start from a main routine
- Stem-and-leaf plot
- 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
- Subleq
- Substring
- 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 squares
- Sum to 100
- Superpermutation minimisation
- Symmetric difference
- System time
T
- Table creation
- Table creation/Postal addresses
- Take notes on the command line
- Tau function
- Tau number
- 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
- Thue-Morse
- Tic-tac-toe
- Tokenize a string
- Tokenize a string with escaping
- Top rank per group
- Totient function
- Towers of Hanoi
- Trabb Pardo–Knuth algorithm
- Tree traversal
- Trigonometric functions
- Truncatable primes
- Truncate a file
- Twin primes
- Two sum
- Type detection