agrep: filter the input lines with a criteria The whole lines that accord to the criteria will be printed Parameters: -i: case insensitivity -w: look for whole words -d {chars}: set the delimiter characters (separators for whole words) -or: or relation between the criterias show the lines that contain any of the search words (default relation: and - show the lines that contain each of the search words) -not: negate the result of the search relation -nand: not-and relation (show each line except the ones containing each search word) -nor: not-or relation -xor: xor relation (show the lines where only one of the search words has been found) -nxor: not-xor relation -r {regexp}: use regular expression -ln: line numbers -not: invert the criteria -e {expression}: use the Eval-based expression (variable: 'line') -oe {expression}: format the output lines with the given expression -f {file}: use the file as input -p[rev] {n}: show the previous n lines before a match -n[ext] {n}: show the next n lines after a match -fetch/-pf {n}: fetch n lines (store in buffer for expression usage) If this is specified, the 'lines' runtime string array can be used to refer to the previous lines (array index: 0 - current line, 1 - previous line, 2 - second prev and so on). The array size is n. -c[ont]: print each line after a valid match -m[ax]: the max number of matches -v {variable_definition}: define a runtime variable -q {expression}: specifiy an expression that is evaluated for each incoming line (before the search criteria for the current line is evaluated) -pq {expression}: expressions that are evaluated after the evaluation of the marching criteria Runtime variables for the expressions: -line: the contents of the current incoming line -lines: the string array of the previous lines (see -pf) -lc: line counter, the number of the current line (starting with 0) -mc: match count -match: the logical value (0/1) of the current line match Examples: agrep -f help.txt Apple -ln -> find the word 'Apple' in the file possible output: 1: I ate an apple\n10: Steve Jobs established Apple in 1976 ... | agrep Windows API -or -> find each line that contains either 'Windows' or 'API' ... | agrep -e "substring(line, 5, 9)=='jacko'" -> find the lines where 'jacko' is at he given position ... | agrep -e "strtok(line, '|', 1) []= 'apple'" -oe "strtok(line, '|', 3)" -> find the lines where the second token contains 'apple', the output will contain only the fourth token of the lines ... | agrep -e -fetch 1 "strcont(line, 'apple') && strcont(lines[1], 'plum')" -> match if the current line contains 'apple' and the previous line contains 'plum' ... | agrep -v "af" -q "af = af | strcont(line, 'apple')" -e "af && strcont(line, 'plum')" -> find each line containing 'plum' only after the first line that contains 'apple' (the expression after '-q' is evaluated for each line -> 'af' becomes true (1) after the first 'apple'-rich line, therefore the evaluating expression gives true value only after such a line) ... | agrep -e "lc % 5 == 0" -> list each 5th line ... | agrep -e "line []= 'apple' && mc < 10" -> list the first ten lines containing 'apple' ... | agrep -v "m" -q "aif(line []= 'apple', m, 1)" -e "m" -> list the lines beginning with the one that contains 'apple' ... | agrep -v "m" -pq "aif(line []= 'apple', m, 1)" -e "m" -> list the lines _after_ the one that contains 'apple'