GNU Find Flashcards: Expressions, Output & Pruning

Predict GNU find output, repair expression grouping and missing prints, and distinguish filtering from directory pruning with 40 short tree-based exercises.

על החפיסה הזו

Practice GNU find expressions with 40 short, original exercises. Read a complete directory tree and command, predict the printed set, explain a missing result or an unexpected directory, or make a restricted repair. The examples separate expression truth, output actions, and directory descent. All fixtures use regular files and directories; output order is irrelevant.

The cards practice tree + command → output or branch explanation, faulty expression + stated goal → one constrained repair, and two commands with equal output → the difference in visited descendants. They move from name/path matching, shell quoting and implicit AND into precedence, grouping, negation and short-circuit printing, then pruning and mixed diagnosis. Closely related variants are separated by at least three other cards. Arbitrary output → command reversal and exhaustive equivalent rewrites are excluded because they do not give a single useful answer.

Scope: -name, -path, -type f/d, implicit/explicit AND, OR, negation, grouping, explicit/default -print, -prune, and one -depth caution showing why children-before-directory traversal defeats pruning. It is not a complete find course. Time, size and permission filters, depth-limit calculations, deletion, command execution, filename transport, symlinks, filesystem races and BSD/macOS portability are outside this deck.

The original trees, questions, answers and order were created with AI assistance. All 40 original fixtures and seven comparison or repair commands were checked with GNU findutils 4.10.0, both directly and through /bin/sh; visited-entry instrumentation checked traversal claims. Behavior facts were checked against the GNU find manual page and the manual included in the GNU findutils 4.10.0 release source. No manual prose, source code, competitor cards or third-party illustrations were copied. The cover is an original AI-generated illustration. CC0 1.0 applies to the original deck text, organization, metadata and cover to the extent applicable rights exist; factual behavior is not owned, and GNU documentation and source retain their own licenses.

An independent, unofficial learning resource with no affiliation with or endorsement by GNU or the Free Software Foundation.

הכרטיסים בחפיסה הזו

  1. כרטיס 1

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    atlas/
    atlas/draft/
    atlas/draft/seed.txt
    atlas/seed.txt
    
    find atlas -name 'draft/seed.txt'
    

    Which paths print?

    תשובה

    None. -name tests the final name component, so a pattern containing / cannot match these names.

  2. כרטיס 2

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    bay/
    bay/card.md/
    bay/card.md/inner
    bay/page.md
    bay/readme.txt
    
    find bay -type f -name '*.md'
    

    Which paths print?

    תשובה

    bay/page.md. Adjacent tests mean AND: the entry must be a regular file and have a name ending in .md.

  3. כרטיס 3

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    cedar/
    cedar/one.log
    cedar/two.log
    cedar/raw/
    cedar/raw/three.log
    
    find cedar -name '*.log'
    

    Why keep the quotes around the pattern?

    תשובה

    They pass the literal pattern *.log to find instead of letting the shell expand it. All three .log files print, including cedar/raw/three.log.

  4. כרטיס 4

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    dune/
    dune/keep.txt
    dune/skip.txt
    dune/skip.txt.box/
    
    find dune -type f ! -name 'skip.txt'
    

    Which paths print?

    תשובה

    dune/keep.txt. ! negates the following name test; the regular-file guard still applies.

  5. כרטיס 5

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    ember/
    ember/first.c
    ember/second.h
    ember/cache.h/
    ember/cache.h/chunk
    
    find ember -type f -name '*.c' -o -name '*.h'
    

    Which paths print?

    תשובה

    ember/first.c, ember/second.h, and directory ember/cache.h. AND binds more tightly than OR, so the .h branch has no regular-file guard.

  6. כרטיס 6

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    fern/
    fern/.note.md
    fern/plain.md
    fern/deep/
    fern/deep/.other.md
    
    find fern -name '*.md'
    

    Which paths print?

    תשובה

    All three .md files. GNU find's -name pattern can match a leading dot; the shell receives the quoted pattern unchanged.

  7. כרטיס 7

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    grove/
    grove/pkg/
    grove/pkg/part.txt
    grove/part.txt
    
    find ./grove -path './grove/pkg/part.txt'
    

    Which paths print?

    תשובה

    ./grove/pkg/part.txt. -path matches the encountered path, including the starting point's ./ prefix.

  8. כרטיס 8

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    harbor/
    harbor/red.txt
    harbor/blue.txt
    harbor/green.txt
    
    find harbor \( -name 'red.txt' -o -name 'blue.txt' \)
    

    Why are the parentheses escaped?

    תשובה

    So the shell passes ( and ) as arguments to find for grouping. The printed set is harbor/red.txt and harbor/blue.txt.

  9. כרטיס 9

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    iris/
    iris/a.csv
    iris/b.tsv
    iris/c.txt
    
    find iris -name '*.csv' -o -name '*.tsv' -print
    

    Which paths print?

    תשובה

    iris/b.tsv only. A true .csv branch short-circuits OR before -print; the explicit action also disables default printing for the command.

  10. כרטיס 10

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    juniper/
    juniper/a.dat
    juniper/b.txt
    juniper/folder.dat/
    
    find juniper -type f -a -name '*.dat' -print
    

    If only -a is removed, does the printed set change?

    תשובה

    No. Both forms print only juniper/a.dat; an omitted operator between primaries means AND.

  11. כרטיס 11

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    kestrel/
    kestrel/a.py
    kestrel/b.pyi
    kestrel/stub.pyi/
    
    find kestrel -type f -name '*.py' -o -name '*.pyi'
    

    Add only grouping parentheses so both name alternatives require a regular file. Give the repaired command.

    תשובה

    find kestrel -type f \( -name '*.py' -o -name '*.pyi' \)
    

    This prints kestrel/a.py and kestrel/b.pyi. The type guard now applies to the whole name choice.

  12. כרטיס 12

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    lagoon/
    lagoon/start.txt
    lagoon/end.txt
    lagoon/other.txt
    
    find lagoon -name 'start.txt' -print -o -name 'end.txt'
    

    Does lagoon/end.txt print?

    תשובה

    No. The second branch is true for it, but that branch has no print action. An explicit -print anywhere in the expression disables default printing for the whole command.

  13. כרטיס 13

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    maple/
    maple/red.txt
    maple/blue.txt
    maple/gray.txt
    
    find maple -type f ! \( -name 'red.txt' -o -name 'blue.txt' \)
    

    Which paths print?

    תשובה

    maple/gray.txt. Negating the grouped OR excludes both named files.

  14. כרטיס 14

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    nectar/
    nectar/a.json
    nectar/b.yaml
    nectar/c.ini
    
    find nectar -name '*.json' -o -name '*.yaml' -print
    

    Add only parentheses so either filename branch reaches the final print. Give the repaired command.

    תשובה

    find nectar \( -name '*.json' -o -name '*.yaml' \) -print
    

    Both nectar/a.json and nectar/b.yaml print; the action is now after the grouped choice.

  15. כרטיס 15

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    opal/
    opal/release notes.txt
    opal/release.txt
    opal/notes.txt
    
    find opal -type f -name 'release notes.txt' -print
    

    Which paths print?

    תשובה

    opal/release notes.txt. The quotes make the space-bearing pattern one shell argument; the space is part of the filename.

  16. כרטיס 16

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    pine/
    pine/real.txt
    
    find pine -name 'absent.txt' -print
    

    With readable entries and no I/O errors, what are the output and exit status?

    תשובה

    No paths; exit status 0. A false selection expression is not a process error.

  17. כרטיס 17

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    quartz/
    quartz/hot.txt
    quartz/cold.txt
    quartz/mild.txt
    
    find quartz -type f \( ! -name 'hot.txt' -o ! -name 'cold.txt' \)
    

    Which paths print?

    תשובה

    All three regular files. Every name differs from at least one of the two distinct names; OR of these negatives excludes neither.

  18. כרטיס 18

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    reed/
    reed/pass.txt
    reed/fail.bin
    
    find reed -print -name '*.txt'
    

    Which paths print?

    תשובה

    reed, reed/pass.txt, and reed/fail.bin. -print runs before the name test; a later false result cannot undo output.

  19. כרטיס 19

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    sable/
    sable/r.c
    sable/s.h
    sable/box.h/
    
    find sable \( -name '*.c' -o -name '*.h' \) -type f -print
    

    Which paths print, and does putting the type test after the group break the guard?

    תשובה

    sable/r.c and sable/s.h. It still works: the grouped name choice and the type test are joined by AND before printing.

  20. כרטיס 20

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    tamarind/
    tamarind/cache/
    tamarind/cache/old.txt
    tamarind/fresh.txt
    
    find tamarind -type d -name 'cache' -prune -o -type f -print
    

    Which paths print, and is cache/old.txt visited?

    תשובה

    Only tamarind/fresh.txt prints. The cache directory is encountered and pruned; its child is not visited. The true pruning branch skips the right side of OR.

  21. כרטיס 21

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    umber/
    umber/yes.txt
    umber/no.txt
    
    find umber -name 'yes.txt' -o -name 'no.txt' -print
    

    For umber/yes.txt, is the full expression true, and does it print?

    תשובה

    The expression is true, but it does not print. The left branch succeeds and OR skips the branch containing the only output action.

  22. כרטיס 22

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    violet/
    violet/cache/
    violet/cache/hidden.txt
    violet/live.txt
    
    find violet -name 'cache' -prune -o -type f
    

    Which paths print?

    תשובה

    violet/cache and violet/live.txt. -prune alone does not disable default printing, and the full expression is true for the pruned directory. Its child is not visited.

  23. כרטיס 23

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    willow/
    willow/build/
    willow/build/a.txt
    willow/vendor/
    willow/vendor/b.txt
    willow/src/
    willow/src/c.txt
    
    find willow -type d \( -name 'build' -o -name 'vendor' \) -prune -o -type f -print
    

    Which paths print?

    תשובה

    willow/src/c.txt only. Both directory names are inside the pruning branch, so neither excluded directory's descendants are visited.

  24. כרטיס 24

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    xenia/
    xenia/cache/
    xenia/cache/a.txt
    xenia/b.txt
    
    find xenia -type f ! -path 'xenia/cache/*' -print
    

    Does this prevent traversal into xenia/cache?

    תשובה

    No. It prints only xenia/b.txt, but still visits xenia/cache/a.txt. A path test filters output; it does not stop directory descent.

  25. כרטיס 25

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    yarrow/
    yarrow/cache/
    yarrow/cache/a.txt
    yarrow/src/
    yarrow/src/cache/
    yarrow/src/cache/b.txt
    yarrow/c.txt
    
    find yarrow -path 'yarrow/cache' -prune -o -type f -print
    

    Which regular files print?

    תשובה

    yarrow/src/cache/b.txt and yarrow/c.txt. Only the exact encountered path yarrow/cache is pruned; the nested cache is a different path.

  26. כרטיס 26

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    zinnia/
    zinnia/cache/
    zinnia/cache/a
    zinnia/b
    
    find zinnia -type d -name 'cache' -prune -print
    

    Does the pruned directory print, and are its children visited?

    תשובה

    zinnia/cache prints; its child is not visited. -prune returns true, so AND continues to the explicit -print for that directory.

  27. כרטיס 27

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    acorn/
    acorn/cache
    acorn/src/
    acorn/src/cache/
    acorn/src/cache/a
    acorn/src/live
    
    find acorn -type d -name 'cache' -prune -o -type f -print
    

    Which paths print?

    תשובה

    acorn/cache and acorn/src/live. The type guard keeps the regular file named cache out of the pruning branch; the nested cache directory is pruned.

  28. כרטיס 28

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    birch/
    birch/build/
    birch/build/a.txt
    birch/vendor/
    birch/vendor/b.txt
    birch/c.txt
    
    find birch -name 'build' -o -name 'vendor' -prune -o -type f -print
    

    Which excluded directory still has its child visited and printed?

    תשובה

    birch/build: its a.txt child prints, along with birch/c.txt. Matching the first OR branch skips -prune; only the vendor branch reaches it.

  29. כרטיס 29

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    cobalt/
    cobalt/cache/
    cobalt/cache/a.txt
    cobalt/b.txt
    
    find cobalt -depth -name 'cache' -prune -o -type f -print
    

    Does pruning prevent the cache child's visit or output?

    תשובה

    No. Both cobalt/cache/a.txt and cobalt/b.txt print. -depth processes children before their directory, so pruning that directory comes too late.

  30. כרטיס 30

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    drift/
    drift/cache/
    drift/cache/a.txt
    drift/lib/
    drift/lib/cache/
    drift/lib/cache/b.txt
    drift/c.txt
    
    find drift -type d -name 'cache' -prune -o -type f -print
    

    Which regular files print?

    תשובה

    drift/c.txt only. A directory-name test catches both the top-level cache and the nested one.

  31. כרטיס 31

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    easel/
    easel/a.txt
    easel/sub/
    easel/sub/b.txt
    
    find easel -name 'easel' -prune -o -type f -print
    

    Which paths print?

    תשובה

    None. The starting directory itself matches and is pruned, so none of its descendants are visited.

  32. כרטיס 32

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    flint/
    flint/cache/
    flint/cache/a.txt
    flint/b.txt
    
    find flint -type d -name 'cache' -prune -type f -print
    

    Why does even flint/b.txt fail to print?

    תשובה

    Every primary is joined by AND. Regular files fail -type d; the pruned cache directory fails -type f. No entry reaches -print.

  33. כרטיס 33

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    garnet/
    garnet/cache/
    garnet/cache/a
    garnet/b
    
    find garnet \( -name 'cache' -prune -o -type f \) -print
    

    Which paths print?

    תשובה

    garnet/cache and garnet/b. The final print applies to either successful branch, including the true pruning branch.

  34. כרטיס 34

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    heath/
    heath/cache/
    heath/cache/a
    heath/lib/
    heath/lib/cache/
    heath/lib/cache/b
    heath/c
    
    find heath -path 'heath/cache' -prune -o -type f -print
    

    Replace only -path 'heath/cache' so every directory named cache is pruned, wherever nested. Give the replacement.

    תשובה

    -type d -name 'cache'. The repaired command prints only heath/c; it prunes both cache directories.

  35. כרטיס 35

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    indigo/
    indigo/.stash/
    indigo/.stash/a.txt
    indigo/.memo.txt
    indigo/b.txt
    
    find indigo -type d -name '.stash' -prune -o -type f -name '*.txt' -print
    

    Which paths print?

    תשובה

    indigo/.memo.txt and indigo/b.txt. The hidden directory is pruned, while the quoted name pattern still matches the hidden regular file.

  36. כרטיס 36

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    jasper/
    jasper/build/
    jasper/build/a
    jasper/vendor/
    jasper/vendor/b
    jasper/c
    
    find jasper -name 'build' -o -name 'vendor' -prune -o -type f -print
    

    Add only parentheses so both named directories reach -prune. Give the repaired command.

    תשובה

    find jasper \( -name 'build' -o -name 'vendor' \) -prune -o -type f -print
    

    Only jasper/c prints. Grouping makes either name lead to the pruning action.

  37. כרטיס 37

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    kelp/
    kelp/cache/
    kelp/cache/a.txt
    kelp/b.txt
    
    find kelp -type f ! -path 'kelp/cache/*' -print
    

    Compare with:

    find kelp -path 'kelp/cache' -prune -o -type f -print
    

    Both commands print kelp/b.txt. Which command still visits kelp/cache/a.txt?

    תשובה

    The first command. Its negated path test hides the descendant from output but does not prevent visiting it; the second command prunes the directory.

  38. כרטיס 38

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    linen/
    linen/cache/
    linen/cache/a.md
    linen/report.md/
    linen/report.md/note.txt
    linen/b.md
    
    find linen -type d -name 'cache' -prune -o -type f -name '*.md' -print
    

    Does directory linen/report.md or its child print?

    תשובה

    Neither. The directory fails the regular-file guard, and its child fails the .md name test. Only linen/b.md prints; report.md is still traversed.

  39. כרטיס 39

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    moss/
    moss/cache/
    moss/cache/a
    moss/b
    
    find ./moss -path 'moss/cache' -prune -o -type f -print
    

    Replace only the path pattern so the cache directory is actually pruned. Give the replacement.

    תשובה

    './moss/cache'. Encountered paths retain the starting point's ./; the repaired command prints only ./moss/b.

  40. כרטיס 40

    שאלה

    GNU find; run from this complete tree's parent. Trailing / marks directories; other entries are regular files. Ignore output order.

    north/
    north/cache/
    north/cache/a.c
    north/src/
    north/src/b.c
    north/src/c.h
    north/src/folder.h/
    north/src/folder.h/d.txt
    north/release notes.h
    
    find north -type d -name 'cache' -prune -o -type f \( -name '*.c' -o -name '*.h' \) -print
    

    Which paths print?

    תשובה

    north/src/b.c, north/src/c.h, and north/release notes.h. Pruning excludes the cache subtree; grouping shares the regular-file guard across both suffixes, so folder.h does not print.

A branching folder tree with a glowing teal route to file icons and an amber barrier before a dimmed branch.

40 כרטיסים

GNU Find Flashcards: Expressions, Output & Pruning

ללמוד את החפיסה הזו בחינם

Nibomo תיפתח כדי שתוכל להתחיל ללמוד.