Quantcast
Viewing all articles
Browse latest Browse all 6

Grep Tip: How To Include or Exclude dotfiles

Obligatory Introduction

Over the years, cmd options have become engrained in my brain.  For grep, they are:

  • grep -Rin (recursive, case-insensitive, line numbers)
  • grep -Ril (recursive, case-insensitive, file names only)
  • -v (lines that don’t match)
  • etc.

Depending on your shell settings (if you include dot globbing or not):

grep [options] [pattern] *

Does not include local dotfiles in your search.  But, changing the asterisk to a period includes everything, including dot files.  This may just be zsh vs. bash.  I haven’t tried with a standard bash shell yet.

tl;dr

To include dotfiles (and folders) in your recursive greps:

grep [options] [pattern] .

Instead of:

grep [options] [pattern] *

Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing all articles
Browse latest Browse all 6

Trending Articles