Search:

PmWiki

pmwiki.org

edit SideBar

Main / Grep

grep -nrsiI <pattern> <directory/file>
(fgrep for fixed strings w/out regexp)

-n = show file line num
-r = recursive
-s = suppress superfluous output
-i = ignore case
-I = ignore binary files

Can make these fixed by putting an options assignment in .bashrc, such as this one that removes backup files from the search
export GREP_OPTIONS="--exclude=\*~"

To search only specific file extensions, use --include=*.{???,?}

To pull out numbers only, use regex like so

grep -o -E '[[:digit:]]*'

This means pull every group of digits of any length.

http://www.linux.org/threads/text-processing-and-manipulation.4107/#post-10309


Page last modified on October 24, 2017, at 10:56 PM