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 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 3 subcategories, out of 3 total.
Pages in category "AWK"
The following 410 pages are in this category, out of 410 total.
A
- A+B
- Abbreviations, automatic
- ABC Problem
- Abundant, deficient and perfect number classifications
- Ackermann function
- Align columns
- Aliquot sequence classifications
- Almost prime
- Amicable pairs
- Anagrams
- Anagrams/Deranged anagrams
- Angle difference between two bearings
- Append a record to the end of a text file
- Apply a callback to an array
- Arithmetic-geometric mean
- Arithmetic/Integer
- Array concatenation
- Array length
- Arrays
- Assertions
- Associative array/Creation
- Associative array/Iteration
- AudioAlarm
- 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
- Calendar
- Call a function
- Case-sensitivity of identifiers
- Catalan numbers
- Character codes
- Check that file exists
- Closest-pair problem
- Collections
- 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
- 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
E
- 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
- Extract file extension
- Extreme floating point values
F
- Factorial
- Factors of an integer
- Farey sequence
- FASTA format
- 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
- Five weekends
- FizzBuzz
- Flow-control structures
- Floyd's triangle
- Formatted numeric output
- Forward difference
- Four is magic
- Function definition
- Function frequency
G
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
I
- I before E except after C
- 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
- Increment a numerical string
- Infinity
- Input loop
- Input/Output for Lines of Text
- Input/Output for Pairs of Numbers
- Integer comparison
- Integer sequence
- Interactive programming
- Introspection
K
L
- Langton's ant
- Largest int from concatenated ints
- Last Friday of each month
- Leap year
- Least common multiple
- Leonardo numbers
- Letter frequency
- Levenshtein distance
- Linux CPU utilization
- Literals/Floating point
- Literals/Integer
- Literals/String
- Logical operations
- Long multiplication
- 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/Infinite
- Loops/N plus one half
- Loops/Nested
- Loops/While
- Lucas-Lehmer test
- Luhn test of credit card numbers
M
N
O
P
- Palindrome detection
- Pangram checker
- Parse command-line arguments
- Parsing/RPN to infix conversion
- Pascal's triangle
- Password generator
- Pathological floating point problems
- Perfect numbers
- Pernicious numbers
- Phrase reversals
- Pick random element
- Power set
- Price fraction
- Primality by trial division
- Prime decomposition
- Probabilistic choice
- Program name
- Program termination
- Proper divisors
R
- 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
- Regular expressions
- Remove duplicate elements
- Remove lines from a file
- 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
- Scope/Function names and labels
- Search a list
- SEDOLs
- Selective File Copy
- Self-describing numbers
- Semordnilap
- Sequence of non-squares
- Sequence of primes by trial division
- Shell one-liner
- Short-circuit evaluation
- Show the epoch
- Sierpinski carpet
- Sierpinski triangle
- Sieve of Eratosthenes
- Singly-linked list/Element definition
- Sleep
- Sort an integer array
- 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
- Spiral matrix
- 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 comments from a string
- Strip control codes and extended characters from a string
- Strip whitespace from a string/Top and tail
- Substring
- Substring/Top and tail
- 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 squares
- Sum to 100
- Symmetric difference
- System time
T
- Table creation
- Table creation/Postal addresses
- Take notes on the command line
- 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
- Text between
- Text processing/1
- Text processing/2
- Text processing/Max licenses in use
- The Twelve Days of Christmas
- Thue-Morse
- Tic-tac-toe
- Tokenize a string
- Tokenize a string with escaping
- Top rank per group
- Towers of Hanoi
- Trabb Pardo–Knuth algorithm
- Tree traversal
- Trigonometric functions
- Truncate a file
- Two Sum