Matcher Selection

[-f FILE, --file=FILE]

الگو‌ها را از فابل بخواند. هر الگو در یک خط نوشته شود

The empty file contains zero patterns, and therefore matches nothing.

[-i, --ignore-case, -y]

عدم حساسیت به حروف بزرگ و کوچک

Ignore case distinctions in both the PATTERN and the input files.

y  سوییچ قدیمی هست و i جدیدتری است

[-v, --invert-match]

الگوی مورد نظر را نشان ندهد

[-w, --word-regexp]
Select  only those lines containing matches that form whole words.
$ grep -w ping  #does not match ping”
[-x, --line-regexp]

درصورتی چیزی پیدا کن که (دقیقا) تمام یک خط  دقیق الگوی وارد شده باشد

$ grep "hello I am behrooz"
 sample3:hello I am behrooz
 sample3:hello I am behrooz! and what is this
 sample3:hello I am behrooz!, I am fine
$ grep -x "hello I am behrooz"
 sample3:hello I am behrooz


General Output Control

[-c, --count]
Count the Number of Matches
$ grep -c salam *.txt
sample1.txt:7
sample2.txt:1
sample3.txt:31
sample4.txt:22
--color[=WHEN], --colour[=WHEN]
export GREP_COLOR='1;32'    #setting green color for pattern
cat file.txt |grep PATTERN --color=auto
[-L, --files-without-match]
فایل‌هایی که الگو را دارا نمی‌باشند
$ grep -L "how" *.txt     #find all files (in the current directory) that do not contain the word "how"
file1.txt
file25.txt
file67.txt
[-l, --files-with-matches]
تنها نام فایل‌هایی که الگو در آن یافت شده است را نشان خواهد داد
$ grep -l "how" *.txt     #find all files (in the current directory) that do not contain the word "how"
file1.txt
file25.txt
file67.txt
 [-m NUM, --max-count=NUM]
Stop  reading a file after NUM matching lines.  If the input is standard input from a regular file, and NUM matching lines are output, grep ensures that the standard input is positioned to just after the last matching line before exiting, regardless
              of the presence of trailing context lines.
This enables a calling process to resume a search.  When grep stops after NUM matching lines, it outputs any trailing context lines.  When the -c or --count option is also used,  grep  does  not  output  a
              count greater than NUM.
When the -v or --invert-match option is also used, grep stops after outputting NUM non-matching lines.

[-o, --only-matching]
Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.

[-q, --quiet, --silent]
Quiet; do not write anything to standard output.  Exit immediately with zero status if any match is found, even if an error was detected.  Also see the -s or --no-messages option.
[-s, --no-messages]
              Suppress error messages about nonexistent or unreadable files.


مشخصات

آخرین جستجو ها