Table of Contents


sfgrep - string matching tool


sfgrep [-h] [-H] [-v] [-c] [-l] [-q] [-1] [-i] string [file(s)]


sfgrep, meant to be something like simple-fixed-grep or string-fast-grep is a small and very fast string matching utility similar to grep.
sfgrep prints lines of file(s) containing the given string. If no filename is given then stdin is used.
sfgrep doesn’t search for a pattern but for an exact string and therefore is very small and fast.
It uses a big read buffer and it also buffers its output to reduce the amount of expensive syscalls. sfgrep doesn’t use mmap() but only open() and read() in a fast way.
It can be used as a fast grep-replacement for many simple purposes but also supplementary with grep as a fast pre-filter in a pipe before grep.


InVert matches: Show only lines not containing the search-string.

Don’t show filename(s).

Always show filename(s).

Don’t show matches but count of matches.

Don’t show matches but only filenames. Stop scanning a file on the first match in file.

Quiet, suppress output.

Just show the first match found and then stop scanning the file.

Case insensitive string search.

See Also



A simple grep replacement example:
$ sfgrep reject /var/log/mail

Used supplementary with grep in a pipe:

$ sfgrep reject list | egrep -v ’spam|uce’


sfgrep may fail on very long lines greater than its read buffer. In this cases the output lines can be scrambled or existing matches can’t be found.
The internal read buffer default size is 256 KB.
Unlike normal and logical people would think the command ’sfgrep -l -c int *.c’ does not show counts but only filenames. This is a small compatibility tribute to the illogical GNU-grep.


Frank Bergmann,

Table of Contents