PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Others

Return the largest file size in a directory

Last updated: Mar 29, 2026

Quick Overview

This question evaluates shell scripting and filesystem manipulation skills, specifically recursive file traversal and file metadata handling using Unix command-line tools, and belongs to the Coding & Algorithms domain (Bash/File System).

  • easy
  • Others
  • Coding & Algorithms
  • Data Scientist

Return the largest file size in a directory

Company: Others

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Take-home Project

## Problem (Bash / File System) Implement a Bash function (or shell snippet) that returns the **maximum file size** (in bytes) under a given directory. ### Requirements - Input: a directory path `DIR` - Consider **regular files only** (ignore directories; you may ignore symlinks unless you explicitly choose to follow them) - Search **recursively** under `DIR` - Output: a single integer = the size (bytes) of the largest file found - If there are no regular files, output `0` ### Example If `DIR` contains files of sizes 10, 25, and 7 bytes (possibly in subdirectories), output `25`.

Quick Answer: This question evaluates shell scripting and filesystem manipulation skills, specifically recursive file traversal and file metadata handling using Unix command-line tools, and belongs to the Coding & Algorithms domain (Bash/File System).

Related Interview Questions

  • Answer k-step ancestor queries in a rooted tree - Others (medium)
  • Answer ancestor-walk queries on a rooted tree - Others (easy)
Others logo
Others
Jan 17, 2026, 12:00 AM
Data Scientist
Take-home Project
Coding & Algorithms
5
0

Problem (Bash / File System)

Implement a Bash function (or shell snippet) that returns the maximum file size (in bytes) under a given directory.

Requirements

  • Input: a directory path DIR
  • Consider regular files only (ignore directories; you may ignore symlinks unless you explicitly choose to follow them)
  • Search recursively under DIR
  • Output: a single integer = the size (bytes) of the largest file found
  • If there are no regular files, output 0

Example

If DIR contains files of sizes 10, 25, and 7 bytes (possibly in subdirectories), output 25.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Others•More Data Scientist•Others Data Scientist•Others Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,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.