← Intuit Interview Insights

Intuit·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

Intuit technical phone screen, bash scripting focus. The question sounds like a warmup until they start asking about edge cases and you realize you should've practiced more than just the happy path.

Questions Asked (1)

Q1

Given a directory, write a bash script to find and return the largest file by size. Walk through multiple approaches, handle filenames with spaces or newlines, and explain how you'd avoid pitfalls when parsing ls output.

Technical Trade-offsAlgorithms & Data Structures
Author's notes

Started with the ls -l approach because it felt natural, and the interviewer let me go down that road for a bit before asking what happens with filenames that have spaces.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (e.g., recursive vs non-recursive, symlinks, hidden files) and then present multiple bash approaches, from simple to robust. Emphasize the pitfalls of parsing ls output and demonstrate safe handling of filenames with spaces or newlines using null delimiters and tools like find, sort, and awk.

Pro tip: Mention that using `ls` for parsing is an anti-pattern because it's designed for human-readable output; instead, use `find -print0` with `sort -z` and `head -z` to safely handle any filename. Also, note that `du` can be used for disk usage but `stat` is better for actual file size.

1. Clarify Requirements

Ask whether the search should be recursive, include hidden files, follow symlinks, and what 'largest' means (apparent size vs disk usage). This shows attention to detail and avoids incorrect assumptions.

2. Present Simple Approach (with caveats)

Show a naive solution like `ls -lS | head -n 2 | tail -n 1` and explain why it's fragile: parsing ls output breaks with spaces, newlines, and special characters in filenames.

3. Introduce Robust Approach Using find and sort

Demonstrate a safe method: `find . -type f -printf '%s %p\0' | sort -z -n -r | head -z -n 1 | cut -z -d' ' -f2-`. Explain how null delimiters prevent issues with spaces and newlines.

4. Discuss Alternative Approaches and Trade-offs

Mention using `du -b` with `sort -n` and `awk`, or a bash loop with `stat`, comparing performance and portability. Highlight that `find -printf` is GNU-specific, so for portability, use `stat` or `du` with null delimiters.

5. Summarize and Emphasize Best Practices

Conclude that avoiding ls parsing, using null delimiters, and testing with edge-case filenames (spaces, newlines, glob characters) is crucial. Offer to write a complete script if needed.

Key Points to Mention

  • Never parse ls output; it's unsafe for filenames with spaces, newlines, or special characters.
  • Use find with -print0 and sort -z to handle null-delimited filenames safely.
  • Consider recursion, hidden files, symlinks, and whether to use apparent size or disk usage.
  • GNU vs BSD tool differences (e.g., find -printf, stat options) affect portability.
  • Performance implications: sorting all files can be memory-intensive for huge directories; consider streaming or using awk to track max.
  • Always test with edge-case filenames (spaces, newlines, leading dashes) to ensure robustness.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.