grep

GREP(1)                     General Commands Manual                    GREP(1)



NAME
       grep, egrep, fgrep - æå°å¹é給å®æ¨¡å¼çè¡

總覽 SYNOPSIS
       grep [options] PATTERN [FILE...]
       grep [options] [-e PATTERN | -f FILE] [FILE...]

æè¿° DESCRIPTION
       Grep æ索以 FILE å½åçæ件輸å¥
       (æèæ¯æ¨æºè¼¸å¥ï¼å¦ææ²ææå®æ件åï¼æè給åºçæ件åæ¯ -
       ç話)ï¼å°æ¾å«æè給å®çæ¨¡å¼ PATTERN ç¸å¹éçå§å®¹çè¡ã é»èªææ³ä¸ï¼ grep
       å°æå«æå¹éå§å®¹çè¡æå°åºä¾ã

       å¦å¤ï¼ä¹å¯ä»¥ä½¿ç¨å©åè®ç¨®ç¨åº egrep å fgrep ã Egrep è grep -E ç¸åã
       Fgrep è grep -F ç¸åã

é¸é  OPTIONS
       -A NUM, --after-context=NUM
              æå°åºç·é¨å¹éçè¡ä¹å¾çä¸æ NUM è¡ãå¨ç¸é°çå¹éçµä¹éå°ææå°å§å®¹æ¯ --
              çä¸è¡ã

       -a, --text
              å°ä¸åäºé²å¶æ件è¦ç²ä¸åææ¬æ件ä¾èçï¼å®è --binary-files=text
              é¸é çå¹ã

       -B NUM, --before-context=NUM
              æå°åºå¹éçè¡ä¹åçä¸æ NUM è¡ãå¨ç¸é°çå¹éçµä¹éå°ææå°å§å®¹æ¯ -- çä¸è¡ã

       -C NUM, --context=NUM
              æå°åºå¹éçè¡çä¸ä¸æåå¾å NUM è¡ãå¨ç¸é°çå¹éçµä¹éå°ææå°å§å®¹æ¯ --
              çä¸è¡ã

       -b, --byte-offset
              å¨è¼¸åºçæ¯è¡åé¢åææå°åºç¶åè¡å¨è¼¸å¥æ件ä¸çåç¯å移éã

       --binary-files=TYPE
              å¦æä¸åæ件çèµ·å§å¹¾ååç¯è¡¨ææ件åå«äºé²å¶æ¸æï¼é£éº¼åå®æä»¶æ¯ TYPE
              é¡åçãé»èªææ³ä¸ï¼ TYPE æ¯ binary ï¼ä¸¦ä¸ grep
              ä¸è¬æ輸åºä¸åä¸è¡çæ¶æ¯èªªä¸åäºé²å¶æ件å¹éï¼æèå¦ææ²æå¹éç話就æ²ææ¶æ¯è¼¸åºãå¦æé¡å
              TYPE æ¯ without-match ï¼é£éº¼ grep åå®äºé²å¶æ件ä¸æå¹éï¼é樣åè
              -I é¸é çå¹ãå¦æé¡å TYPE æ¯ text ï¼é£éº¼ grep
              å°ä¸åäºé²å¶æ件è¦ç²ææ¬æ件ä¾èçï¼å®è -a é¸é çå¹ã è¦åï¼ grep
              --binary-files=text å¯è½æ輸åºäºé²å¶çç¡ç¨å§å®¹ãå¦æ輸åºè¨‐
              åæ¯ä¸åçµç«¯ï¼ä¸¦ä¸çµç«¯çé©åå°éäºè¼¸åºä¸‐
              çä¸äºç¶ä½å½ä»¤ï¼å¯è½æ帶ä¾æ¡å£çå¯ä½ç¨ã

       --colour[=WHEN], --color[=WHEN]
              å¨å¹éçè¡å¨å以 GREP_COLOR ç°å¢è®éä¸æå®çè¨èä¾æ¨è¨ãWHEN å¯ä»¥æ¯
              `never', `always', ææ¯ `auto'ã

       -c, --count
              ç¦æ‐
              ¢é常ç輸åºï¼ä½ç²æ¿ä»£ï¼ç²æ¯ä¸å輸å¥æ件æå°ä¸åå¹éçè¡ç總æ¸ãå¦æ使ç¨
              -v, --invert-match é¸é  (åè¦ä¸é¢)ï¼å°æ¯ä¸å¹éçè¡ç總æ¸ã

       -D ACTION, --devices=ACTION
              å¦æ輸å¥æ件æ¯ä¸åè¨åï¼FIFO ææ¯å¥æ¥å (socket) ï¼ä½¿ç¨åä½ ACTION
              ä¾èçå®ãé»èªææ³ä¸ï¼åä½ ACTION æ¯ read ï¼æå³çè¨‐
              åå°è¦ç²æ®éæ件é£æ¨£ä¾è®ãå¦æåä½ ACTION æ¯ skip
              ï¼å°ä¸èçèç´æ¥è·³éè¨åã

       -d ACTION, --directories=ACTION
              å¦æ輸å¥æ件æ¯ä¸åç®éï¼ä½¿ç¨åä½ ACTION ä¾èçå®ãé»èªææ³ä¸ï¼åä½
              ACTION æ¯ read ï¼æå³çç®éå°è¦ç²æ®éæ件é£æ¨£ä¾è®ãå¦æåä½ ACTION æ¯
              skip ï¼å°ä¸èçèç´æ¥è·³éç®éãå¦æåä½ ACTION æ¯ recurse ï¼ grep å°éæ‐
              ¸å°è®æ¯ä¸ç®éä¸çæææ件ãé樣åå -r é¸é çå¹ã

       -E, --extended-regexp
              å°æ¨¡å¼ PATTERN ä½ç²ä¸åæ´å±çæ£å表éå¼ä¾è§£é (åè¦ä¸é¢)ã

       -e PATTERN, --regexp=PATTERN
              使ç¨æ¨¡å¼ PATTERN ä½ç²æ¨¡å¼ï¼å¨ä¿è·ä»¥ - ç²èµ·å§ç模å¼ææç¨ã

       -F, --fixed-strings
              å°æ¨¡å¼ PATTERN è¦ç²ä¸ååºå®çå符串çå表ï¼ç¨æ°è¡ (newlines)
              åéï¼åªè¦å¹éå¶ä¸ä¹ä¸å³å¯ã

       -P, --perl-regexp
              å°æ¨¡å¼ PATTERN ä½ç²ä¸å Perl æ£å表éå¼ä¾è§£éã

       -f FILE, --file=FILE
              å¾æ件 FILE ä¸ç²å模å¼ï¼æ¯è¡ä¸åã空æ件å«æ0å模å¼ï¼å æ‐
              ¤ä¸å¹éä»»ä½æ±è¥¿ã

       -G, --basic-regexp
              å°æ¨¡å¼ PATTERN ä½ç²ä¸ååºæ¬çæ£å表éå¼ (åè¦ä¸é¢)
              ä¾è§£éãéæ¯é»èªå¼ã

       -H, --with-filename
              ç²æ¯åå¹éæå°æ件åã

       -h, --no-filename
              ç¶æç´¢å¤åæ件æï¼ç¦æ¢å¨è¼¸åºçåé¢å ä¸æ件åå綴ã

       --help 輸åºä¸åç°¡çç幫å©ä¿¡æ¯ã

       -I     èçä¸åäºé²å¶æ件ï¼ä½æ¯èªç²å®ä¸åå«å¹éçå§å®¹ãéå --binary-
              files=without-match é¸é çå¹ã

       -i, --ignore-case
              忽ç¥æ¨¡å¼ PATTERN å輸å¥æ件ä¸ç大å°å¯«çåå¥ã

       -L, --files-without-match
              ç¦æ‐
              ¢é常ç輸åºï¼ä½ç²æ¿ä»£ï¼æå°åºæ¯åå¨é常ææ³ä¸ä¸æç¢ç輸åºç輸å¥æ件çåå‐
              ãå°æ¯åæ件çææå¨éå°ç¬¬ä¸åå¹éçæåå°±æåæ¢ã

       -l, --files-with-matches
              ç¦æ‐
              ¢é常ç輸åºï¼ä½ç²æ¿ä»£ï¼æå°åºæ¯åå¨é常ææ³ä¸æç¢ç輸åºç輸å¥æ件çåå‐
              ãå°æ¯åæ件çææå¨éå°ç¬¬ä¸åå¹éçæåå°±æåæ¢ã

       -m NUM, --max-count=NUM
              å¨æ¾å° NUM
              åå¹éçè¡ä¹å¾ï¼ä¸åè®éåæ件ãå¦æ輸å¥æ¯ä¾èªä¸åæ®éæ件çæ¨æºè¼¸å¥ï¼ä¸¦ä¸å·²ç¶è¼¸åºäº
              NUM åå¹éçè¡ï¼ grep ä¿è‐
              æ¨æºè¼¸å¥è¢«å®ä½æ¼éåºæçæå¾ä¸æ¬¡å¹éçè¡ä¹å¾ï¼ä¸ç®¡æ¯å¦æå®äºè¦è¼¸åºç·é¨çä¸æçè¡ãé樣å¯ä»¥ä½¿ä¸å調ç¨ç¨åºæ¢å¾©æç´¢ãç¶
              grep å¨ NUM åå¹éçè¡ä¹å¾åæ¢ï¼å®æ輸åºä»»ä½ç·é¨çä¸æçè¡ãç¶ä½¿ç¨äº
              -c æ --count é¸é çæåï¼ grep ä¸æ輸åºæ¯ NUM æ´å¤çè¡ãç¶æå®äº -v æ
              --invert-match é¸é çæåï¼ grep æå¨è¼¸åº NUM åä¸å¹éçè¡ä¹å¾åæ¢ã

       --mmap å¦æå¯è½ç話ï¼ä½¿ç¨ mmap(2) 系統調ç¨ä¾è®å輸å¥ï¼èä¸æ¯é»èªç
              read(2) 系統調ç¨ãå¨ä¸äºææ³ä¸ï¼ --mmap
              æä¾è¼å¥½çæ§è½ãä½æ¯ï¼å¦æä¸å輸å¥æä»¶å¨ grep æ‐
              £å¨æä½æ大å°ç¼çè®åï¼æèå¦æç¼çäºä¸å I/O é¯èª¤ï¼ --mmap
              å¯è½å°è´ä¸å¯ç¥çè¡ç² (åæ¬core dumps)ã

       -n, --line-number
              å¨è¼¸åºçæ¯è¡åé¢å ä¸å®æå¨çæ件ä¸å®çè¡èã

       -o, --only-matching
              åªé¡¯ç¤ºå¹éçè¡ä¸è PATTERN ç¸å¹éçé¨åã

       --label=LABEL
              å°å¯¦éä¸ä¾èªæ¨æºè¼¸å¥ç輸å¥è¦ç²ä¾èªè¼¸å¥æ件 LABEL ãéå°æ¼ zgrep
              é樣çå·¥å·é常æç¨ï¼ä¾å¦ï¼ gzip -cd foo.gz |grep --label=foo
              something

       --line-buffering
              使ç¨è¡ç·©è¡ï¼it can be a performance penality.

       -q, --quiet, --silent
              å®éãä¸åæ¨æºè¼¸åºå¯«ä»»ä½æ±è¥¿ãå¦ææ¾å°ä»»ä½å¹éçå§å®¹å°±ç«å³ä»¥çæå¼
              0 éåºï¼å³ä½¿æª¢æ¸¬å°äºé¯èª¤ã åè¦ -s æ --no-messages é¸é ã

       -R, -r, --recursive
              éæ¸å°è®æ¯ä¸ç®éä¸çæææ件ãé樣åå -d recurse é¸é çå¹ã

         --include=PATTERN
              ååå¨æç´¢å¹é PATTERN çæ件æå¨ç®éä¸éæ¸æç´¢ã

         --exclude=PATTERN
              å¨ç®éä¸éæ¸æç´¢ï¼ä½æ¯è·³éå¹é PATTERN çæ件ã

       -s, --no-messages
              ç¦æ¢è¼¸åºéæ¼æ件ä¸åå¨æä¸å¯è®çé¯èª¤ä¿¡æ¯ã å°æ¼å¯ç§»æ¤æ§éè¦æ³¨æï¼è
              GNU grep ä¸åï¼å³çµ±ç grep ä¸éµå® POSIX.2 è¦ç¯ï¼å ç²å³çµ±ç grep
              缺å°ä¸å -q é¸é ï¼èå®ç -s é¸é è GNU grep ç -q
              é¸é è¡ç²ç¸ä¼¼ãéè¦å¯ç§»æ¤å°å³çµ± grep ç shell è³æ¬æç¶é¿åä½¿ç¨ -q
              å -s é¸é ï¼èæç¶å°è¼¸åºéå®åå° /dev/null ã

       -U, --binary
              å°æ件è¦ç²äºé²å¶ãé»èªææ³ä¸ï¼å¨ MS-DOS å MS-Windows 系統ä¸ï¼
              grep ééå¾æ件ä¸è®åé é¨ç 32kB å§å®¹ä¾å¤æ·å®çæ件é¡åãå¦æ grep
              å¤æ·æ件æ¯ä¸åææ¬æ件ï¼å®å°åå§æ件å§å®¹ä¸ç CR å符å»é¤ (使å¾å«æ
              ^ å $ çæ£å表éå¼å¯ä»¥æ£å¸¸å·¥ä½)ãæå® -U
              å°ä¸é²è¡éäºå·¥ä½ï¼è使æææ件ä¿æä¸è®å°è®å並å³é給å¹éæ©å¶ãå¦ææ件æ¯ä¸å以
              CR/LF æè¡çææ¬æ件ï¼é樣ä½å°å°è´ä¸äºæ£å表éå¼å¤±æãéåé¸é å¨ MS-DOS
              å MS-Windows ä¹å¤ç系統ä¸ç¡æã

       -u, --unix-byte-offsets
              å ±å Unix é¢¨æ ¼çåç¯å移éãéåééä½¿å¾ grep å ±åå‐
              ç¯å移éæï¼å°æ件ä½ç² Unix é¢¨æ ¼çææ¬æ件çå¾ï¼ä¹å°±æ¯èªªå° CR å‐
              符å»æãéå°ç¢çèå¨ä¸èº Unix 主æ©ä¸éè¡ grep å®å¨ç¸åççµæãé¤éåæ使ç¨
              -b é¸é ï¼å¦åéåé¸é ç¡æãéåé¸é å¨ MS-DOS å MS-Windows
              ä¹å¤ç系統ä¸ç¡æã

       -V, --version
              åæ¨æºé¯èª¤è¼¸åºæå° grep ççæ¬èãçæ¬èæç¶åå«å¨ææç bug å ±åä¸
              (åè¦ä¸é¢)ã

       -v, --invert-match
              æ¹è®å¹éçæ義ï¼åªé¸æä¸å¹éçè¡ã

       -w, --word-regexp
              åªé¸æå«æè½çµæå®æ´çè©çå¹éçè¡ãå¤æ·æ¹æ³æ¯å¹éçåå‐
              符串å¿é æ¯ä¸è¡çéå§ï¼æèæ¯å¨ä¸åä¸å¯è½æ¯è©ççµæçå符ä¹å¾ãèæ‐
              ¤ç¸ä¼¼ï¼å®å¿é æ¯ä¸è¡ççµæï¼æèæ¯å¨ä¸åä¸å¯è½æ¯è©ççµæçå‐
              符ä¹åãè©ççµæå符æ¯åæ¯ï¼æ¸åï¼éæä¸åç·ã

       -x, --line-regexp
              åªé¸æè½å¹éå®æ´ä¸è¡çå¹éã

       -y     -i çå義è©ï¼å»¢æ£ä¸ç¨ã

       -Z, --null
              輸åºä¸åå¨é¶åç¯ (ASCII 碼ä¸ç NUL å符)
              èä¸æ¯ä¸è¬ææ³ä¸è¼¸åºå¨æ件åä¹å¾çå符ãä¾å¦ï¼ grep -lZ
              å¨æ¯åæ件åä¹å¾è¼¸åºä¸åå¨é¶å‐
              ç¯èä¸æ¯æ®éçæ°è¡ç¬¦ãéåé¸é 使å¾è¼¸åºæ¸æ¥æç½ï¼å³ä½¿æ件åç表示ä¸‐
              åå«ç¹æ®å符æ¯å¦æ°è¡ç¬¦ãéåé¸é å¯ä»¥èå½ä»¤ find -print0, perl -0,
              sort -z, å xargs -0
              ä¸èµ·ä½¿ç¨ï¼ä¾èçä»»æçæ件åï¼å³ä½¿æ¯é£äºå«ææ°è¡ç¬¦çæ件åã

æ£å表éå¼ REGULAR EXPRESSIONS
       ä¸åæ£å表éå¼æ¯ä¸åæè¿°äºä¸åå符串éåç模å¼ãæ‐
       £å表éå¼çæ§é é¡ä¼¼æ¼ç®è¡è¡¨éå¼ï¼ä½¿ç¨å種å樣çæä½ç¬¦ä¾å°æ´å°ç表éå¼é£å¨ä¸èµ·ã

       Grep è½ç解å©ç¨®ä¸åçæ¬çæ£å表éå¼èªæ³ï¼“basic” å “extended”ãå¨ GNU grep
       ä¸ï¼å©ç¨®èªæ³å¯ä»¥å¯¦ç¾çåè½æ¯æ²æåå¥çãå¨å¶ä»å¯¦ç¾ä¸ï¼åºæ¬ (basic) æ‐
       £å表éå¼è¡¨éè½åè¦å¼±ä¸é»ãä¸é¢çæè¿°é©ç¨æ¼æ´å±ç (extended) æ‐
       £å表éå¼ï¼å®èåºæ¬æ£å表éå¼çåå¥æå¨æå¾åä¸å總çµã

       åºæ¬çæ§é å¡æ¯å¹éå®åå符çæ£å表éå¼ã大é¨åå符ï¼åæ¬ææåæ¯åæ¸å‐
       ï¼æ¯å¹éå®åèªèº«çæ£å表éå¼ãä»»ä½å·æç¹æ®å«ç¾©çåå‐
       符å¯ä»¥ééåç½®ä¸ååææ§ä¾å¼ç¨ã(may be quoted by preceding it with a
       backslash.)

       æ¹æ¬è表éå¼ (bracket) æ¯ä¸åå符åºåï¼æ¾å¨ [ å ] ç¶ä¸ãå®å¹éåºåä¸‐
       çä»»ä½ä¸åå符ï¼å¦æåºåä¸ç第ä¸åå符æ¯è«å符 (caret) ^ é£éº¼å®å¹é ä¸å¨
       åºåä¸çä»»ä½ä¸åå符ãä¾å¦ï¼æ£å表éå¼ [0123456789] å¹éä»»ä½ä¸åæ¸åã

       å¨æ¹æ¬è表éå¼ä¹ä¸ï¼ä¸å ç¯å表éå¼ (range) ç±å©åå符çµæï¼ä¸éç¨ä¸åé£å符
       (hyphen) åéãå®å¹éå¨éå©åå符ä¹éçä»»ä½ä¸åå符ï¼ä½¿ç¨æ¬å°åçåºåé åºåå‐
       符éã(that sorts between the two characters,inclusive, using the
       locale's collating sequence and character set.) ä¾å¦ï¼å¨é»èªç C
       localeä¸ï¼ [a-d] è [abcd] çå¹ãå¸åçï¼è¨±å¤ locale å°å符以å‐
       å¸é åºæåºï¼å¨éäº locale ä¸ï¼ [a-d] ä¸è [abcd] çå¹ï¼ä¾å¦å®å¯è½è
       [aBbCcDd] çå¹ãè¦ç²å¾å³çµ±çå°æ¹æ¬è表éå¼ç解éï¼å¯ä»¥è¨å®ç°å¢è®é LC_ALL
       å¼ç² C ä¾ä½¿ç¨ locale C ã

       æå¾ï¼å¨æ¹æ¬è表éå¼ä¸æä¸äºé å®ç¾©çå符é¡ï¼å¦ä¸æ示ãå®åçåå‐
       æ¯èªèªªæçï¼å®åæ¯ [:alnum:](åæ¯åæ¸å), [:alpha:](åæ¯), [:cntrl:](),
       [:digit:](æ¸å), [:graph:](), [:lower:](å°å¯«åæ¯), [:print:](å¯æå°å符),
       [:punct:](), [:space:](ç©ºæ ¼), [:upper:](大寫åæ¯), å [:xdigit:]
       ãä¾å¦ï¼ [[:alnum:]] æææ¯ [0-9A-Za-z] ï¼ä½æ¯å¾ä¸ç¨®è¡¨ç¤ºæ¹æ³ä¾è³´æ¼
       locale C åASCII å符編碼ï¼èåä¸ç¨®æ¯è locale åå符éç¡éçã(注æéäºå‐
       符é¡åä¸çæ¹æ¬èä¹æ¯ç¬¦èå稱çä¸é¨åï¼å¿é åå«å¨ç¨ä¾ç²åºåå®ççæ¹æ¬èä¹ä¸ã)

       大å¤æ¸åå符èæ¼åºåä¸ææ失å»å®åçç¹æ®æ義ãç²äºåå«ä¸ååé¢æ義 (literal) ç ]
       ï¼éè¦å°å®æ¾å¨åºåçæåãèæ¤ç¸ä¼¼ï¼ç²äºåå«ä¸ååé¢æ義 (literal) ç ^
       ï¼éè¦å°å®æ¾å¨é¤äºåºåæåä¹å¤çå¶ä»ä½ç½®ãæå¾ï¼ç²äºåå«ä¸ååé¢æ義 (literal) ç
       - ï¼éè¦å°å®æ¾å¨åºåæå¾ã

       å¥é»ç¬¦ (period) .  å¹éä»»ä½ä¸åå符ã符è \w æ¯ [[:alnum:]] çå義è©ï¼ \W
       æ¯ [^[:alnum]] çå義è©ã

       è«å符 (caret) ^ åç¾åæ¨è¨ (dollar) $ åå¥æ¯å¹éä¸è¡çé¦é¨åå°¾é¨ç空å‐
       串çåå符ã符è \< å \> åå¥æ¯å¹éä¸åè©çé¦é¨åå°¾é¨ç空å串çåå符ã符è \b
       å¹éä¸åè©éç·£ (edge) ç空å串ï¼ç¬¦è \B å¹é ä¸ èæ¼ä¸åè©çéç·£ç空å串ã

       ä¸åæ£å表éå¼å¾é¢å¯ä»¥è·é¨å¤ç¨®éè¤æä½ç¬¦ä¹ä¸ã
       ?      ååçé æ¯å¯é¸çï¼æå¤å¹éä¸æ¬¡ã
       *      ååçé å¯ä»¥å¹éé¶æ¬¡æå¤æ¬¡ã
       +      ååçé å¯ä»¥å¹éä¸æ¬¡æå¤æ¬¡ã
       {n}    ååçé å°å¹éæ°å¥½ n 次ã
       {n,}   ååçé å¯ä»¥å¹é n ææ´å¤æ¬¡ã
       {n,m}  ååçé å°å¹éè³å° n è©ï¼ä½æ¯ä¸æè¶é m 次ã

       å©åæ£å表éå¼å¯ä»¥é£æ¥å°ä¸èµ·ï¼å¾åºçæ‐
       £å表éå¼å¯ä»¥å¹éä»»ä½ç±å©ååå¥å¹éé£æ¥åçå表éå¼çåå符串é£æ¥èæçå符串ã

       å©åæ£å表éå¼å¯ä»¥ç¨ä¸ç¶´æä½ç¬¦ | è¯åå°ä¸èµ·ï¼å¾åºçæ‐
       £å表éå¼å¯ä»¥å¹éä»»ä½å¹éè¯ååçä»»ä½ä¸åå表éå¼çå符串ã

       éè¤æä½ç¬¦çåªåç´æ¯é£æ¥é«ï¼æ¥ä¸ä¾åæ¯é¸æçåªåç´é«ãä¸åå®æ´çå‐
       表éå¼å¯ä»¥ç¨åæ¬è (parentheses) æ¬ä½ä¾è¶è¶éäºåªåç´è¦åã(to override
       these precedence rules.)

       ååå¼ç¨ \n ä¸ï¼ n æ¯ä¸åæ¸åï¼å¹éæ£å表éå¼ä¸ï¼ä»¥ç¬¬ n ååæ¬èæ¬ä½çå‐
       表éå¼å·²å¹éçåå符串ã

       å¨åºæ¬æ£å表éå¼ä¸ï¼åå符 ?, +, {, |, (, å )
       åªå¤±äºå®åçç¹æ®æ義ï¼ä½ç²æ¿ä»£ï¼ä½¿ç¨å åææ§ç (backslash) çæ¬ \?, \+,
       \{, \|, \(, å \) ã

       å³çµ±ç egrep ä¸æ¯æåå符 { ï¼ä¸¦ä¸ä¸äº egrep ç實ç¾ééæ¯æ \{
       ä¾ä»£æ¿å®ï¼å æ¤å¯ç§»æ¤çè³æ¬æç¶é¿å å¨ egrep ä¸ä½¿ç¨ { 模å¼ï¼æç¶ä½¿ç¨
       [{] ä¾å¹éä¸ååé¢æ義 (literal) ç { ã

       GNU egrep ééåè¨å¦æ { èæ¼ an invalid interval specification
       çèµ·å§ï¼å°±ä¸æ¯ä¸åç¹æ®å符ï¼ä¾æ¯æå³çµ±çç¨æ³ãä¾å¦ï¼shell å½ä»¤ egrep
       '{1' å°ææç´¢éåå©å符çå符串 {1 èä¸æ¯å ±åå¨æ£å表éå¼ä¸‐
       ç¼çäºèªæ³é¯èª¤ãPOSIX.2
       å許éåè¡ç²ï¼å°å¶è¦ç²ä¸åæ´å±ï¼ä½æ¯å¯ç§»æ¤çè³æ¬æç¶é¿å使ç¨å®ã

ç°å¢è®é ENVIRONMENT VARIABLES
       Grep çè¡ç²åä¸åç°å¢è®éå½±é¿ã

       ä¸å locale LC_foo æ¯ééæä¸é¢çé åºï¼ LC_ALL, LC_foo, LANG,
       檢æ¥éä¸åç°å¢è®éçåå¼è確å®çãè¨ç½®äºç第ä¸åè®éæå®äº localeãä¾å¦ï¼å¦æ
       LC_ALL æ²æè¨ç½®ï¼ä½æ¯ LC_MESSAGES è¨ç½®ç² pt_BR ï¼é£éº¼å·´è¥¿çè¡èçèª
       (Brazilian Portuguese) å°ç¨ä½ LC_MESSAGES locale çå¼ãå¦ææ²æè¨ç½®éå¶ä¸‐
       ä»»ä½ä¸åç°å¢è®éï¼æèæ²æå®è£æè¨ç½®ç locale ç®éï¼æèå¦æ grep
       æ²æå°å家åèªè¨æ¯æ (national language support (NLS)) ç·¨è‐
       ¯å¨å§ï¼å°é»èªä½¿ç¨ locale Cã

       GREP_OPTIONS
              éåè®éæå®äºå°æ¾å¨ææ顯å¼æå®çé¸é ä¹åçé»èªé¸é ãä¾å¦ï¼å¦æ
              GREP_OPTIONS æ¯ '--binary-files=without-match
              --directories=skip' çè©±ï¼ grep
              å°åå·²ç¶å¨ä»»ä½é¡¯å¼æå®çé¸é ä¹åæå®äº --binary-files=without-
              match å --directories=skip é¸é é£æ¨£ä¾éä½ãé¸é 以空ç½
              (whitespace) åéãä¸ååææ§ (backslash) 使å¾ä¸ä¸åå符è½ç¾©
              (escape)ï¼å æ¤å¯ä»¥ç¨ä¾æå®ä¸åå«æ空ç½æèåææ§çé¸é ã

       GREP_COLOR
              æå®ç¨ä¾é«äº®é¡¯ç¤ºçæ¨è¨ã

       LC_ALL, LC_COLLATE, LANG
              éäºè®éæå®äº locale LC_COLLATE ï¼æ±ºå®äºè§£éé¡ä¼¼ [a-z]
              çç¯å表éå¼æçåºåé åº (collating sequence) ã

       LC_ALL, LC_CTYPE, LANG
              éäºé¸é æå®äº locale LC_CTYPE ï¼æ±ºå®äºå符çé¡åï¼ä¾å¦ï¼åªäºå‐
              符æ¯ç©ºç½ (whitespace) ã

       LC_ALL, LC_MESSAGES, LANG
              éäºé¸é æå®äº locale LC_MESSAGES ï¼æ±ºå®äº grep
              çæ¶æ¯ä½¿ç¨çèªè¨ãé»èªç locale C 使ç¨ç¾åè±èªçæ¶æ¯ã

       POSIXLY_CORRECT
              å¦æè¨ç½®äºçè©±ï¼ grep å°å POSIX.2 è¦æ±çé£æ¨£ä¾éä½ï¼å¦åï¼ grep
              å°åå¶ä» GNU ç¨åºä¸æ¨£ä¾éä½ãPOSIX.2
              è¦æ±æ件åä¹å¾çé¸é å¿é è¦ç²æ件åï¼é»èªææ³ä¸ï¼éäºé¸é 被交æå°æä½æ¸å表çåé¢ï¼è¢«ç¶ä½é¸é ä¾èçãåæï¼
              POSIX.2 è¦æ±ä¸å¯èå¥çé¸é å¨è¨ºæ·æ¶æ¯ä¸è¡¨ç¤ºç²
              “illegal”ï¼ä½æ¯æ¢ç¶å®åæ²æçæ£è§¸ç¯æ³å¾ï¼å æ¤é»èªææ³ä¸å®åå¨è¨ºæ·
              (diagnose) æ¶æ¯ä¸è¡¨ç¤ºç² “invalid”ã POSIXLY_CORRECT åæç¦æ‐
              ¢äºä¸é¢æè¿°ç _N_GNU_nonoption_argv_flags_ã

       _N_GNU_nonoption_argv_flags_
              (éè£ N æ¯ grep's æ¸åå½¢å¼çé²ç¨IDã) å¦æéåç°å¢è®éçå¼ç第 i åå符æ¯
              1 ï¼é£éº¼ä¸å° grep ç第 i åæä½æ¸è¦ç²ä¸åé¸é ï¼å³ä½¿å®çä¸å»åãshell
              å¯ä»¥å°éåè®éè¨ç½®å¨å®éè¡çæ¯åå½ä»¤çç°å¢ä¸‐
              ï¼æå®åªåæä½æ¸æ¯æ件åéé符æ´å±ççµæï¼å æ‐
              ¤ä¸æç¶è¢«è¦ç²é¸é ãéåè¡ç²åªæå¨ä½¿ç¨ GNU C 庫æææï¼ä¸¦ä¸åªæå¨
              POSIXLY_CORRECT æ²æè¨ç½®çæåã

è¨ºæ· DIAGNOSTICS
       ä¸è¬å°ï¼å¦ææ¾å°äºé¸æçè¡ï¼éåºæçæå¼ç²0ï¼å¦åç²1ãä½æ¯å¦æç¼çé¯èª¤ï¼éåºæçæå¼æ¯2ï¼é¤éæå®äº
       -q æ --quiet æ --silent é¸é ï¼ä¸¦ä¸æ¾å°äºé¸æçè¡ã

BUGS
       bug å ±åçé»åéµä»¶å°åæ¯ bug-gnu-utils@gnu.orgã ä¸å®è¦å¨“Subject:”ä¸å¸¶æ
       “grep” éåè©ã

       å¨ {n,m} çµæ§ä¸éè¤æ¬¡æ¸éå¤æå°è´ grep 使ç¨å¤§éå§åãå¦å¤ï¼ä¸äºéåæ¦æ¾çæ‐
       £å表éå¼éè¦ææ¸ç´çæéå空éï¼å¯è½æå°è´ grep èç¡ææå§åã

       åå¾å¼ç¨ (backreferences) é常æ¢ï¼å¯è½éè¦ææ¸ç´çæéã

[ä¸æçç¶è·äºº]
       è¢ä¹é <bbbush@163.com>

[ä¸æçææ°æ´æ°]
       2003.11.03

ãä¸ålinuxè«å£manæåé ç¿»è¯è¨åã:
       http://cmpp.linuxforum.net

è·
       æ¬é é¢ä¸æçç±ä¸æ man æåé è¨åæä¾ã
       ä¸æ man æåé è¨åï¼https://github.com/man-pages-zh/manpages-zh



                                  GNU Project                          GREP(1)