Grep Grep Commands Justin Seara Overview of Grep

  • Slides: 7
Download presentation
Grep & Grep Commands Justin Seara

Grep & Grep Commands Justin Seara

Overview of Grep Command line tool Searches for files using regular expressions Regular Expressions

Overview of Grep Command line tool Searches for files using regular expressions Regular Expressions Used for pattern matching Allows quick and easy searching

Regular Expressions Most A-Z and 0 -9 characters stand for themselves Some characters have

Regular Expressions Most A-Z and 0 -9 characters stand for themselves Some characters have special meaning Called Allow The Metacharacters for more complex regular expressions actual character can be represented by: character

Regexp Examples [abc] - Will match either a, b, or c, once [0 -9]

Regexp Examples [abc] - Will match either a, b, or c, once [0 -9] - Will match any number once s – Whitespace {m} – m repetitions ? - Optional () - Capture whole group . * - Variable Content w – Any alphanumeric character d – any digit

Variations of grep -E – Extended grep program grep -F – Fast grep program

Variations of grep -E – Extended grep program grep -F – Fast grep program Extended character support for ASCII Does not allow the use of regexp grep -P - Interprets in perl Highly experimental

How To Use Grep grep [OPTIONS] … PATTERN [FILES] OPTIONS : -c –count -i

How To Use Grep grep [OPTIONS] … PATTERN [FILES] OPTIONS : -c –count -i – ignore-case -n – line-number -f –file [FILES] Files are unnecessary grep reads standard input Piping!

Uses of grep Searching large files Searching systems Searching for errors in code Gathering

Uses of grep Searching large files Searching systems Searching for errors in code Gathering metrics on a file