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.
- -v
- InVert matches: Show only lines not containing the search-string.
- -h
- Don’t
show filename(s).
- -H
- Always show filename(s).
- -c
- Don’t show matches but count
of matches.
- -l
- Don’t show matches but only filenames. Stop scanning a file
on the first match in file.
- -q
- Quiet, suppress output.
- -1
- Just show the first
match found and then stop scanning the file.
- -i
- Case insensitive string
search.
grep(1)
http://www.tuxad.de/
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 1 MB.
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, http://www.tuxad.com
Table of Contents