读懂grep文档

man grep

文档部分

General Commands Manual:GREP(1)

NAME

  • grep, egrep, fgrep, rgrep - print lines matching a pattern

SYNOPSIS

  • grep [OPTIONS] PATTERN [FILE…]
  • grep [OPTIONS] [-e PATTERN | -f FILE] [FILE…]

DESCRIPTION

  • grep searches the named input FILEs (or standard input if no files are named, or if a single hyphen-minus (-) is given as file name) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.
  • In addition, three variant programs egrep, fgrep and rgrep are available. egrep is the same as grep -E. fgrep is the same as grep -F. rgrep is the same as grep -r. Direct invocation as either egrep or fgrep is deprecated, but is provided to allow historical applications that rely on them to run unmodified.

OPTIONS

  • Generic Program Information

    • –help Print a usage message briefly summarizing these command-line options and the bug-reporting address, then exit.
    • -V, –version
      • Print the version number of grep to the standard output stream.This version number should be included in all bug reports (see below).
  • Matcher Selection

    • -E, –extended-regexp

      • Interpret PATTERN as an extended regular expression (ERE, see below). (-E is specified by POSIX.)
    • -F, –fixed-strings

      • Interpret PATTERN as a list of fixed strings, separated by newlines, any of which is to be matched. (-F is specified by POSIX.)
    • -G, –basic-regexp

      • Interpret PATTERN as a basic regular expression (BRE, see below). This is the default.
    • -P, –perl-regexp

      • Interpret PATTERN as a Perl regular expression (PCRE, see below). This is highly experimental and grep -P may warn of unimplemented features.
  • Matching Control
  • General output Control
  • Output Line Prefix Control
  • Context Line Control
  • File and Directory Selection
  • Other Options
    REGULAR EXPRESSIONS
  • Character Classes and Bracket Expressions
  • Anchoring
  • The Backslash Character and Special Expressions
  • Repetition
  • Concatenation
  • Alternation
  • Precedence
  • Back References and Subexpressions
  • Basic vs Extended Regular Expressions

ENVIRONMENT VARIABLES

  • GREP_OPTIONS
  • GREP_COLOR
  • GREP_COLORS
  • LC_ALL, LC_COLLATE, LANG
  • LC_ALL, LC_CTYPE, LANG
  • LC_ALL, LC_MESSAGES, LANG
  • POSIXLY_CORRECT
  • _N_GNU_nonoption_argvflags
    EXIT STATUS
    COPYRIGHT
    BUGS
  • Reporting Bugs
  • Known Bugs
    SEE ALSO
  • Regular Manual Pages
  • POSIX Programmer’s Manual Page
  • TeXinfo Documentation
    NOTES

理解

障碍词语

SYNOPSIS:提要,概要。
hyphen-minus:hyphen(连字符,连(字)号)。
variant:变体,变化形式。

学习感受

这个命令太复杂,不适合入门,换一个命令

http://cn.linux.vbird.org/linux_basic/0160startlinux.php#cmd_cmd

Changelog

161118 新建