0. NAME
ag Anthony's Grep
1. SYNOPSIS
ag <pattern> [file...]
2. DESCRIPTION
The AG utility shall search input files, selecting lines matching a
pattern. An input line shall be selected if the pattern, treated as a
subset of Extended Regular Expressions as described by POSIX.2
Standard section 2.8.4, matches any part of the line; a null pattern
shall match every line. Each selected input line shall be written to
the standard output.
Regular expression matching shall be based on text lines, which are
separated by a <newline> character. A regular expression cannot
contain a <newline> and there is no way for a pattern to match a
<newline> found in the input.
3. OPTIONS
None.
4. OPERANDS
pattern Specify one pattern to be used during the search for
input. See Extended Regular Exprssions below on what
constitutes a valid pattern.
file A pathname of a file to be searched for the pattern.
If no file operands are specified or the file operand
is dash (-), the standard input shall be used.
5. EXTERNINAL INFLUENCES
5.1. STANDARD INPUT
The standard input shall be used only if no file operands are
specifed. See Input Files.
5.2. INPUT FILES
The input files shall be text files.
5.3. ENVIRONMENT VARIABLES
No environment variables are used.
5.4. ASYNCHRONOUS EVENTS
Default.
6. EXTERNAL EFFECTS
6.1. STANDARD OUTPUT
For each selected input line from a file, a single output line shall
be written:
"%s:%s\n", file, line
Standard input will have the filename dash (-).
6.2. STANDARD ERROR
Standard error is used for diagnostic messages only.
6.3. OUTPUT FILES
None.
7. EXTENDED DESCRIPTION
7.1. EXTENDED REGULAR EXPRESSIONS
7.1.1. MATCHING A SINGLE CHARACTER
An ERE ordinary character, a special character preceded by a
backslash, or a period shall match a single character. A bracket
expression shall match a single character. An ERE matching a single
character enclosed in parentheses shall match the same as the ERE
without parentheses would have matched.
7.1.1.1. ERE ORDINARY CHARACTERS
An oridinary character is an ERE that matches itself. An ordinary
character is any character in the supported character set, except for
the ERE special characters listed in 7.1.1.2. The interpretation of
an ordinary character preceded by a backslash (\) is the ordinary
character.
7.1.1.2. ERE SPECIAL CHARACTERS
An ERE special character has special properties in certain contexts.
Outside of those contexts, or when preceded by a backslash, such a
character shall be an ERE that matches the special character itself.
The extended regular expression special characters and the contexts in
which they have their special meaning are:
. [ \ ( The period, left-bracket, backslash, and left-
parenthesis are special except when used in a
bracket expression. Outside a bracket
expression, a left-parenthesis immediately
followed by a right-parenthesis will be
treated as a null expression.
) The right-parenthesis is special when matched
with a preceding left-parenthesis, both
outside of a bracket expression.
* ? The asterisk and question-mark are special
except when used in a bracket expression.
Results are undefined if this character
appears first in an ERE, or immediately
following a vertial-line, circumflex, or
left-parenthesis.
| The vertical-line is special except when used
in a bracket expression. A vertical-line
appearing first or last in an ERE or
immediately following a vertical-line or
left-parenthesis, or preceding a
right-parenthesis, produces a null expression.
^ The circumflex shall be special when used as
an anchor or, as the first character of a
bracket expression.
$ The dollar-sign shall be special when used as
an anchor.
7.1.1.3 PERIODS IN ERE
A period (.), when used outside of a bracket expression, is an ERE
that shall match any character in the supported character set except
NUL.
7.1.2. ERE BRACKET EXPRESSION
A bracket expression (an expression enclosed in square brackets, []),
is an ERE that matches a single character contained in the nonempty
set of characters represented by the bracket expression.
The following rules and definitions apply to bracket expressions:
1) A bracket expression is either a matching list expression
or a nonmatching list expression. It consists of one or more
characters and/or range expressions. The right-bracket (])
shall lose its special meaning and represent itself in a
bracket expression if it occurs first in the list [after an
initial circumflex (^), if any]. Otherwise, it shall
terminate the bracket expression. The special characters
period (.), asterisk (*), left-bracket ([), and backslash (\)
shall lose their special meaning within a bracket expression.
2) A matching list expression specifies a list that shall match
any one of the expressions represented in the list. The first
character of the list shall not be the circumflex. For
example, [abc] is an ERE that matches any of a, b, or c.
3) A nonmatching list expression begins with a circumflex (^),
and specifies a list that shall match any character except for
the expressions represented in the list after the leading
circumflex. For example, [^abc] is an ERE that matches any
character except a, b, or c. The circumflex shall have this
special meaning only when it occurs first in the list,
immediately following the left-bracket.
4) A range expression represents the set of characters that
fall between two elements in the current collation sequence,
inclusive. It shall be expressed as the starting point and
the ending point separated by a hyphen (-).
In the following, all examples assume the collation sequence
specified for the POSIX Locale (a.k.a ASCII Character Set),
unless another collation sequence is sepecifically defined
by the hardware.
The starting range point and the ending range point shall be a
collating element (character). The ending range point shall
collate higher than the starting range point; otherwise the
expression shall be treated as invalid.
The interpretation of a range expression where the ending
range point is the starting range point of a subsequent range
expression is undefined.
The hyphen character shall be treated as itself if it occurs
first (after an initial ^, if any) or last in the list, or as
an ending range point in a range expression. As examples, the
expressions [-ac] and [ac-] are equivalent and match any of
the characters a, c, or -; the expressions [^-ac] and [^ac-]
are equivalent and match ant character except a, c, -; the
expression [%--] matches any of the characters between % and
- inclusive; the expression [--@] matches any of the
characters between - and @ inclusive; and the expression
[a--@] is invalid, because the letter a follows the symbol -
in the POSIX Locale.
7.1.3. ERE MATCHING MULTIPLE CHARACTERS
The following rules shall be used to construct EREs matching multiple
characters from EREs matching a single character:
1) A concatenation of EREs shall match the concatenation of the
character sequences matched by each component of the ERE. A
concatenation of EREs enclosed in parentheses shall match
whatever the concatenation without parentheses matches. For
example, both the ERE cd and the ERE (cd) are matched by the
third and forth character of the string abcdefabcdef.
2) When an ERE matching a single character, or a concatention of
EREs enclosed in parentheses is followed by the special
character asterisk (*), together with that asterisk it shall
match what zero or more consecutive occurences of the ERE
would match. For example, the ERE b*c matches the first
character in the string cabbbcde, and the ERE b*cd matches the
third through seventh characters in the string
cabbbcdebbbbbbcdbc. And, [ab]* and
没有合适的资源?快使用搜索试试~ 我知道了~
混乱c代码大赛获奖作品集
共598个文件
c:233个
hint:181个
readme:20个
需积分: 12 5 下载量 132 浏览量
2010-06-30
16:35:57
上传
评论
收藏 1.41MB RAR 举报
温馨提示
混乱c代码大赛获奖作品集,很有意思,但是看看把
资源推荐
资源详情
资源评论
收起资源包目录
混乱c代码大赛获奖作品集 (598个子文件)
samefile.1 4KB
adrian.grep.1 131B
demo1.1st 212B
adrian.grep.2 64B
adrian.grep.3 99B
adrian.grep.4 48B
adrian.grep.5 60B
boot.b 6KB
LANDER.BAS 2KB
LANDER.BAS 2KB
tvr.bw 730B
mkentry.c 35KB
mkentry.c 35KB
mkentry.c 34KB
mkentry.c 34KB
mkentry.c 34KB
mkentry.c 33KB
mkentry.c 33KB
mkentry.c 33KB
mkentry.c 32KB
vik2.c 4KB
dgbeards.c 4KB
jdalbec.c 4KB
jason.c 4KB
horton.alt.c 4KB
williams.c 4KB
arachnid.c 4KB
arachnid.orig.c 4KB
sds.c 4KB
herrmann1.c 3KB
gavin.c 3KB
omoikane.c 3KB
bellard.otccex.c 3KB
bellard.c 3KB
dloweneil.c 3KB
schweikh2.c 3KB
spinellis.c 3KB
august.c 3KB
august.orig.c 3KB
vern.c 3KB
vern.orig.c 3KB
newbern.c 3KB
newbern.orig.c 3KB
shapiro.c 3KB
thadgavin.orig.c 3KB
dhyang.c 3KB
albert.c 3KB
albert.orig.c 3KB
gtface.c 3KB
dlowe.c 3KB
rcm.c 3KB
tvr.c 3KB
westley.c 3KB
dodsond1.c 3KB
vik1.c 3KB
rince.c 3KB
ant.c 3KB
heathbar.c 3KB
tvr.alt.c 3KB
thadgavin.c 3KB
robison.c 3KB
schweikh3.c 3KB
rince.c 3KB
dodsond1.c 3KB
schneiderwent.c 3KB
schneiderwent.orig.c 3KB
briddlebane.c 3KB
anonymous.c 3KB
dodsond2.c 3KB
anonymous.c 3KB
adrian.c 3KB
adrian.orig.c 3KB
ant.c 2KB
kev.c 2KB
bmeyer.c 2KB
huffman.c 2KB
ejb.c 2KB
fanf.c 2KB
bas1.c 2KB
garry.fmt.c 2KB
banks.orig.c 2KB
banks.c 2KB
leo.c 2KB
buzzard.1.c 2KB
leo.orig.c 2KB
jonth.c 2KB
schnitzi.c 2KB
schnitzi.c 2KB
schweikh1.c 2KB
vanschnitz.c 2KB
dgibson.c 2KB
westley.orig.c 2KB
westley.c 2KB
kivinen.c 2KB
schnitzi.c 2KB
kivinen.orig.c 2KB
imc.c 2KB
chaos.c 2KB
coupard.c 2KB
schweikh1.c 2KB
共 598 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
xero_123
- 粉丝: 35
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功