GMATCH(1) NAME fgrep SYNOPSIS fgrep [-ghinsv] [-f $num] [-F $sep] pattern [file ...] DESCRIPTION Gmatch is a simple pattern match tool that follows glob expression. The options are same as those of grep: -g the pattern is a glob pattern. -h Do not print file name tags. -i Ignore alphabetic case distinctions. -n Mark each printed line with its line number. -s Produce no output, but return status. -v Reverse: print lines that do not match the pattern. -f $num: field number that begins with 1,2,... -F $sep: field separator Fgrep is a field oriented grep. Don't confuse with obsolete fgrep that is the grep with -f option. Fgrep can be replaced by grep if none of the next options is given: "-g", "-f" and "-F" Grep is faster than fgrep. The glob patterns are same as those of rc script except: (a) somewhat extended. regular expression symbols "(", ")" and "|" are allowed. These meanings are same as that of regular expression. (b) the next symbols are not allowed in the pattern: "\", "^", "$" The pattern is searched line wise. Be careful that fgrep -g 'foo' is equivalent to grep '^foo$' and grep 'foo' is equivalent to fgrep '*foo*' NOTE The performance comparison is shown below. term% ls -l main --rw-rw-r-- M 149 arisawa arisawa 246720704 May 6 19:58 main The contents are something like: term% grep alice main |p abalice 000000000006c67e alice 000000000001a2bc ... term% time grep alice main >/dev/null # cache the main 0.76u 0.17s 26.27r grep alice main term% time grep alice main >/dev/null # effect of cache 0.32u 0.07s 1.55r grep alice main term% time grep -v alice main >/dev/null 0.55u 0.03s 1.77r grep -v alice main term% tab=' ' term% time kirara/fgrep -f1 -F $tab 'alice' main >/dev/null 0.92u 0.06s 2.36r kirara/fgrep -f1 -F alice ... term% time kirara/fgrep -vf1 -F $tab 'alice' main >/dev/null 1.79u 0.08s 4.31r kirara/fgrep -vf1 -F alice ... term% time kirara/fgrep -gf1 -F $tab '*alice*' main >/dev/null 2.23u 0.05s 5.20r kirara/fgrep -gf1 -F *alice* ... term% time kirara/fgrep -vgf1 -F $tab '*alice*' main >/dev/null 3.57u 0.13s 7.21r kirara/fgrep -vgf1 -F *alice* ... If you want speed, take hybrid strategie: term% date -n; grep alice main | kirara/fgrep -gf1 -F $tab '*alice*' >/dev/null;date -n 1399505278 1399505280 Speed comparison to awk: term% time awk -F $tab '$1 ~ /alice/{print}' main >/dev/null 3.94u 0.26s 6.96r awk -F $1 ~ /alice/{print} main ... term% time awk -F $tab '$1 !~ /alice/{print}' main >/dev/null 5.43u 0.20s 8.31r awk -F $1 !~ /alice/{print} main ... term% NOTE Grep option "-i" works only for ascii charactors. The problem is fixed in fgrep. (confirmed only using Russian text) AUTHER Kenji Arisawa