PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/System Design/Amazon

Design a file search module like UNIX find

Last updated: Apr 19, 2026

Quick Overview

This question evaluates object-oriented and API design skills, filesystem semantics (pattern matching, file types, timestamps, permissions, symlink handling), traversal and concurrency strategies, and robustness for large or error-prone directory trees.

  • hard
  • Amazon
  • System Design
  • Software Engineer

Design a file search module like UNIX find

Company: Amazon

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Onsite

Design an object-oriented module that mimics the UNIX 'find' command to search the filesystem by criteria. Requirements: support filtering by name pattern (glob/regex), file type (file/dir/link), size ranges, modification/creation time, permissions/owner, and depth limits; allow composing predicates with AND/OR/NOT; provide options for following or skipping symlinks; and support outputting paths or file metadata. Propose APIs for command-style and library usage, show how to extend with new filters, discuss traversal and performance (early pruning, concurrency), and address robustness for large directories and permission errors. Provide class diagrams or interfaces, key data structures, and test cases.

Quick Answer: This question evaluates object-oriented and API design skills, filesystem semantics (pattern matching, file types, timestamps, permissions, symlink handling), traversal and concurrency strategies, and robustness for large or error-prone directory trees.

Related Interview Questions

  • Design a cloud database write path and recovery - Amazon (hard)
  • Design a replicated cloud storage service - Amazon (hard)
  • Measure platform success and drive adoption - Amazon (medium)
  • Design multi-tenant ingestion and processing platform - Amazon (medium)
  • Design globally consistent metadata service - Amazon (medium)
Amazon logo
Amazon
Aug 13, 2025, 12:00 AM
Software Engineer
Onsite
System Design
15
0

Design Task: Object-Oriented module that mimics UNIX find

Context

Design an object-oriented library that replicates the core functionality of the UNIX find command for searching a filesystem by various criteria. The module should be usable as a library and also expose a command-style fluent API for easy composition.

Functional Requirements

  • Filters
    • Name pattern: glob and regex
    • File type: file, directory, symlink
    • Size ranges: e.g., >10 MB, between 1–5 KB
    • Times: modification time (mtime), creation/birth time (if available), change time (ctime)
    • Permissions/owner/group
    • Depth limits: maxDepth, minDepth
  • Predicate composition: AND, OR, NOT
  • Symlink handling: options to follow or skip symlinks; prevent cycles
  • Outputs: emit path strings and/or structured file metadata

Non-Functional Requirements

  • Traversal and performance
    • Early pruning of subtrees when possible (depth/type/name pre-checks)
    • Optional concurrency: parallel directory traversal with backpressure
    • Efficient directory iteration and stat calls
  • Robustness
    • Handle very large directories and deep trees without recursion overflow
    • Graceful handling of permission errors, races (file disappears), broken symlinks
    • Cancellation and timeouts

Deliverables

  • Proposed APIs
    • Command-style fluent builder
    • Library-style iterator/stream API
  • Extensibility: how to add new filters/predicates
  • Traversal algorithm and performance considerations
  • Robustness/error-handling strategy
  • Class diagrams or interfaces and key data structures
  • Representative test cases

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon System Design•Software Engineer System Design
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.