find a file

Find a file by its name, by when it changed, or by what is written in it.

  • files
  • search

Steps

  1. find . -iname '*report*'

    files under this folder with "report" in the name, any case

  2. locate -i report

    the same over the whole machine, from an index, at once

  3. find . -mtime -1

    files changed in the last day

  4. grep -rIl 'some text' .

    files under this folder that contain the text

  5. grep -rn 'some text' .

    the lines that contain it, with file and line number

  6. rg 'some text'

    the same, faster, with ripgrep

Notes

  • locate knows only what was there when its index was last made: sudo updatedb makes it again.
  • In grep, -I skips binary files and -l prints only the file names.

Commands used

  • find
  • locate
  • grep
  • rg
  • fd

Each has a page in lore: lore find opens it.