5.4 Search patterns in files

5.4.1 Search for pattern (grep)

5.4.2 The Silver Searcher (ag)

ag is command-line software to recursively search a PATTERN in a specific PATH. It can be used from the command line as ag [options] PATTERN [PATH].

  • You can use -u option to include hidden files in the search.
  • Use the option --html to search only on html files. The command ag --list-file-types provides the supported file-types.
  • The files to search on can also be filtered with -G PATTERN. For example ag -G .html$ PATTERN is similar as using option --html. Use -g PATTERN to print files matching the PATTERN (e.g. ag -g .html$).

See some examples below: