Skip to content

Quiz: fd

← Back to quiz index

4 questions

L0 (2 questions)

1. How does fd differ from find in handling .gitignore files?

Show answer fd respects .gitignore by default, automatically skipping ignored files and directories. find has no awareness of .gitignore and searches everything.

2. What are the key differences between fd and find?

Show answer fd is faster (parallel directory traversal), has sane defaults (ignores .gitignore, hidden files), uses regex by default, and has simpler syntax. Example: fd 'test.*\.py$' vs find . -name 'test*.py'. fd respects .gitignore; find does not. fd colorizes output. Use find when you need POSIX portability or -exec with complex logic.

L1 (1 questions)

1. What is the difference between fd --exec and fd --exec-batch, and when would you use each?

Show answer --exec runs the command once per match (in parallel). --exec-batch runs the command once with all matches as arguments (like xargs). Use --exec for per-file operations (e.g., compiling), --exec-batch for tools that accept multiple files at once (e.g., shellcheck, ruff).

L2 (1 questions)

1. You need to find all shell scripts modified in the last 7 days, excluding node_modules, and verify they pass syntax checks. Write the fd command.

Show answer fd -e sh -E node_modules --changed-within 7d --exec-batch bash -n. This uses extension filter, exclusion, time filter, and batch execution to syntax-check all matching scripts in one pass.