Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
InfrastructureJuniorOccasionalPractical

What is the difference between `find` and `grep` on Linux?

Answer

`find` searches filesystem entries using criteria such as name, path, type, size or modification time. `grep` searches text content for matching lines or patterns. They are often combined: use `find` to select files and `grep` to inspect their content, or use recursive `grep -R` when content search is the main task.

Strong answer includes

  • find searches filesystem metadata and paths
  • grep searches file or stream content
  • knows when to combine them safely

Practical example

To locate JSON logs changed today and inspect them for a correlation ID, first use `find /var/log/app -name '*.json' -mtime 0`, then search the selected files with `grep -n 'abc-123'`.

#linux#find#grep#filesystem

Sources

GNU grep manualGNU Project · Text search, matching options, recursive search and grep command semanticsLinux man-pages projectman7.org / Linux man-pages project · Linux processes, signals, networking and system-call-facing command behavior50 Linux Interview Questions (With Answers)Toolmingo · Recurrence signal for Linux filesystem, permissions, processes, systemd, networking and shell-command interview topics