この項目では、UNIXの検索コマンドについて説明しています。同人ショップについては「グレップ」をご覧ください。
grep(グレップ、グレプ)は、UNIXおよびUnixオペレーティングシステムにおけるコマンド。テキストファイル中から、正規表現に一致する行を検索して出力する。 grep の名の由来は、ラインエディタedのコマンド g/re/p である。その意味するところは「global regular expression print(ファイル全体から/正規表現に一致する行を/表示する)」で略号になっている[1]。 姉妹コマンドとして、正規表現ではなくリテラル(即値文字列)のみを扱う高速な fgrep[2]、拡張正規表現が使える egrep[3] がある。POSIX では fgrep、egrep を旧形式としていて、それぞれ grep -F、grep -E を使うことを標準としている。Linux Standard Baseでも指定コマンドになっている[4]。 grep コマンドの基本的な使い方はgrep オプション パターン ファイル である。 ファイルは複数指定することができ、また省略して標準入力から検索することもできる。 オプションには次のようなものがある: テキストから文字列を検索するプログラムとして、有志により、 Microsoft Windows 用にgrepWin
概要
使用法
-i : アルファベットの大文字小文字の区別をしない。
-o:パターンに一致した箇所のみ出力する。
-v : パターンに一致しない行を出力する。
-r : ファイルとしてディレクトリを指定し、その中の全てのファイルと、再帰的に下位ディレクトリに対して検索する。
-q:何も出力しない。
-E : 拡張正規表現を使用する。egrep コマンドと同じ動作をする。
-F : 正規表現ではなくリテラルを使用する。fgrep コマンドと同じ動作をする。
移植
参考文献
Brian W. Kerninghan、ロブ・パイク『UNIXプログラミング環境』野中浩一
脚注[脚注の使い方]^ 英: search globally in the file / each lines to which the regular expression matches / print them
^ 英: fixed grep または fast grep
^ 英: extended grep
^ Linux Standard Base https://refspecs.linuxfoundation.org/lsb.shtml
^ https://github.com/stefankueng/grepWin
この項目は、ソフトウェアに関連した書きかけの項目です。この項目を加筆・訂正などしてくださる協力者を求めています(PJ:コンピュータ/P:コンピュータ)。
.mw-parser-output .hlist ul,.mw-parser-output .hlist ol{padding-left:0}.mw-parser-output .hlist li,.mw-parser-output .hlist dd,.mw-parser-output .hlist dt{margin-right:0;display:inline-block;white-space:nowrap}.mw-parser-output .hlist dt:after,.mw-parser-output .hlist dd:after,.mw-parser-output .hlist li:after{white-space:normal}.mw-parser-output .hlist li:after,.mw-parser-output .hlist dd:after{content:" ・\a0 ";font-weight:bold}.mw-parser-output .hlist dt:after{content:": "}.mw-parser-output .hlist-pipe dd:after,.mw-parser-output .hlist-pipe li:after{content:" |\a0 ";font-weight:normal}.mw-parser-output .hlist-hyphen dd:after,.mw-parser-output .hlist-hyphen li:after{content:" -\a0 ";font-weight:normal}.mw-parser-output .hlist-comma dd:after,.mw-parser-output .hlist-comma li:after{content:"、";font-weight:normal}.mw-parser-output .hlist-slash dd:after,.mw-parser-output .hlist-slash li:after{content:" /\a0 ";font-weight:normal}.mw-parser-output .hlist dd:last-child:after,.mw-parser-output .hlist dt:last-child:after,.mw-parser-output .hlist li:last-child:after{content:none}.mw-parser-output .hlist dd dd:first-child:before,.mw-parser-output .hlist dd dt:first-child:before,.mw-parser-output .hlist dd li:first-child:before,.mw-parser-output .hlist dt dd:first-child:before,.mw-parser-output .hlist dt dt:first-child:before,.mw-parser-output .hlist dt li:first-child:before,.mw-parser-output .hlist li dd:first-child:before,.mw-parser-output .hlist li dt:first-child:before,.mw-parser-output .hlist li li:first-child:before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child:after,.mw-parser-output .hlist dd dt:last-child:after,.mw-parser-output .hlist dd li:last-child:after,.mw-parser-output .hlist dt dd:last-child:after,.mw-parser-output .hlist dt dt:last-child:after,.mw-parser-output .hlist dt li:last-child:after,.mw-parser-output .hlist li dd:last-child:after,.mw-parser-output .hlist li dt:last-child:after,.mw-parser-output .hlist li li:last-child:after{content:")\a0 ";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li:before{content:" "counter(listitem)" ";white-space:nowrap}.mw-parser-output .hlist dd ol>li:first-child:before,.mw-parser-output .hlist dt ol>li:first-child:before,.mw-parser-output .hlist li ol>li:first-child:before{content:" ("counter(listitem)" "}.mw-parser-output .navbar{display:inline;font-size:75%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}.mw-parser-output .infobox .navbar{font-size:88%}.mw-parser-output .navbox .navbar{display:block;font-size:88%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}
表示
編集
表
話
編
歴
Unixコマンド
ファイルとファイルシステム管理
cat
chattr(英語版)
chmod
chown
chgrp
cksum
cmp
cp
dd
du
df(英語版)
file
fsck
fuser(英語版)
ln
ls
lsof
mkdir
mount
mv
pax
pwd
rm
rmdir
size
split
tee
touch
type(英語版)
umask(英語版)
プロセス管理
at
bg
chroot
cron
fg