---
name: "hfst-grep"
section: "1"
platform: "linux"
package: "hfst"
version: "3.16.2-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/hfst-grep"
---

# hfst-grep(1)

\=Search for PATTERN in each FILE or standard input.

## NAME

hfst-grep - =Search for PATTERN in each FILE or standard input.

## SYNOPSIS

**hfst-grep** \[*OPTIONS*...\] *PATTERN* \[*FILE*...\]

## DESCRIPTION

Search for PATTERN in each FILE or standard input. Pattern is, by default, a Xerox regular expression (XRE). Example: hfst-grep 'h e l l o %  w o r l d' menu.h menu.c

### Common options:

- **-h**, **--help**

  Print help message

- **-V**, **--version**

  Print version info

- **-v**, **--verbose**

  Print verbosely while processing

- **-q**, **--quiet**

  Only print fatal erros and requested output

- **-s**, **--silent**

  Alias of **--quiet**

- **-9**, **--format**=*TYPE*

  compile expressions to TYPE automata

### Regexp selection and interpretation:

- **-E**, **--extended-regexp**

  PATTERN is an extended regular expression (ERE)

- **-F**, **--fixed-strings**

  PATTERN is a set of newline-separated fixed strings

- **-G**, **--basic-regexp**

  PATTERN is a basic regular expression (BRE)

- **-P**, **--perl-regexp**

  PATTERN is a Perl regular expression

- **-X**, **--xerox-regexp**

  PATTERN is a Xerox regulare expression

- **-e**, **--regexp**=*PATTERN*

  use PATTERN for matching

- **-f**, **--file**=*FILE*

  obtain PATTERN from FILE

- **-I**, **--ignore-case**

  ignore case distinctions

- **-w**, **--word-regexp**

  force PATTERN to match only whole words

- **-x**, **--line-regexp**

  force PATTERN to match only whole lines

- **-z**, **--null-data**

  a data line ends in 0 byte, not newline

### Miscellaneous options:

- **--no-messages**

  suppress error messages

- **--invert-match**

  select non-matching lines

### Output control:

- **-m**, **--max-count**=*NUM*

  stop after NUM matches\\n  **-b**, **--byte-offset**         print the byte offset with output lines

- **-n**, **--line-number**

  print line number with output lines

- **--line-buffered**

  flush output on every line

- **-H**, **--with-filename**

  print the filename for each match

- **-h**, **--no-filename**

  suppress the prefixing filename on output

- **--label**=*LABEL*

  print LABEL as filename for standard input

- **-o**, **--only-matching**

  show only the part of a line matching PATTERN

- **--binary-files**=*TYPE*

  assume that binary files are TYPE; TYPE is \`binary', \`text', or \`without-match'

- **-a**, **--text**

  equivalent to **--binary-files**=*text*

- **-d**, **--directories**=*ACTION*

  how to handle directories; ACTION is \`read', \`recurse', or \`skip'

- **-D**, **--devices**=*ACTION*

  how to handle devices, FIFOs and sockets; ACTION is \`read' or \`skip'

- **-R**, **-r**, **--recursive**

  equivalent to **--directories**=*recurse*

- **--include**=*FILE\_PATTERN*

  search only files that match FILE\_PATTERN

- **--exclude**=*FILE\_PATTERN*

  skip files and directories matching FILE\_PATTERN

- **--exclude-from**=*FILE*

  skip files matching any file pattern from FILE

- **--exclude-dir**=*PATTERN*

  directories that match PATTERN will be skipped

- **-L**, **--files-without-match**

  print only names of FILEs containing  no match

- **-l**, **--files-with-matches**

  print only names of FILEs containing matches

- **-c**, **--count**

  print only a count of matching lines per FILE

- **-T**, **--initial-tab**

  make tabs line up (if needed)

- **-Z**, **--null**

  print 0 byte after FILE name

### Context control:

- **-B**, **--before-context**=*NUM*

  print NUM lines of leading context

- **-A**, **--after-context**=*NUM*

  print NUM lines of trailing context

- **-C**, **--context**=*NUM*

  print NUM lines of output context

**--color**\[=*WHEN*\],

- **--colour**\[=*WHEN*\]

  use markers to highlight the matching strings; WHEN is \`always', \`never', or \`auto'

- **-U**, **--binary**

  do not strip CR characters at EOL (MSDOS)

- **-u**, **--unix-byte-offsets**

  report offsets as if CRs were not there (MSDOS)

## REPORTING BUGS

Report bugs to \<hfst-bugs@helsinki.fi\> or directly to our bug tracker at: \<https://github.com/hfst/hfst/issues\> hfst-grep home page: \<https://github.com/hfst/hfst/wiki/HfstGrep\>\
 General help using HFST software: \<https://github.com/hfst/hfst/wiki\>

## COPYRIGHT

Copyright © 2017 University of Helsinki, License GPLv3: GNU GPL version 3 \<http://gnu.org/licenses/gpl.html\>\
 This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
