GNU find Depth Flashcards: -maxdepth and -mindepth
Practice GNU find depth limits with short command and output drills. Predict which paths print and choose -maxdepth and -mindepth for the levels you need.
ਇਸ ਡੈੱਕ ਬਾਰੇ
Trace GNU find through small directory trees. Predict which paths print, write commands for a target depth or range, and fix off-by-one errors. Each answer gives the result and a short explanation.
Start at depth zero and with direct children. Then combine -mindepth and -maxdepth for exact levels and inclusive ranges. Later cards mix depth with file and directory tests, hidden entries, multiple starting points, and a case where a minimum depth blocks pruning.
The examples focus on listing paths. File changes, cross-platform syntax, and output order are outside the scope. These original exercises were drafted with AI assistance and checked against GNU Findutils.
ਇਸ ਡੈੱਕ ਦੇ ਕਾਰਡ
ਕਾਰਡ 1
ਸਵਾਲ
What depth does GNU
findassign to a starting point?ਜਵਾਬ
Depth 0. With
find vault,vaultitself is at depth 0.ਕਾਰਡ 2
ਸਵਾਲ
Which GNU
findoption limits how far it descends?ਜਵਾਬ
-maxdepth N. GNUfindcan visit entries at depthNand stops descending there.ਕਾਰਡ 3
ਸਵਾਲ
Which GNU
findoption skips tests and actions on entries shallower than a given depth?ਜਵਾਬ
-mindepth N. Tests and actions start at depthN. The minimum by itself still allows descent through shallower directories.ਕਾਰਡ 4
ਸਵਾਲ
kioskis a directory. What does this GNUfindcommand print?find kiosk -maxdepth 0 -type f -printਜਵਾਬ
No paths print. Only
kioskis eligible by depth, and-type faccepts regular files.ਕਾਰਡ 5
ਸਵਾਲ
When GNU
findstarts atboard, what is the depth of its direct childboard/pin?ਜਵਾਬ
Depth 1. Moving from a directory to any of its children adds one level.
ਕਾਰਡ 6
ਸਵਾਲ
Which paths does this GNU
findcommand print, in any order?orchard/ ├── basket/ │ └── spare └── mapfind orchard -maxdepth 1 -printਜਵਾਬ
orchard orchard/basket orchard/mapThe starting directory is at depth 0. Its direct children are at depth 1.
ਕਾਰਡ 7
ਸਵਾਲ
Which paths does GNU
findprint, in any order?lab/ ├── meter └── bench/ └── cablefind lab -mindepth 1 -printਜਵਾਬ
lab/meter lab/bench lab/bench/cableThe starting point is skipped. Its children and deeper descendants are eligible.
ਕਾਰਡ 8
ਸਵਾਲ
Using GNU
find, print the pathticketonly if that starting point is a regular file.ਜਵਾਬ
find ticket -maxdepth 0 -type f -printDepth 0 selects the named starting point.
-type fchecks whether it is a regular file.ਕਾਰਡ 9
ਸਵਾਲ
Which depth options make GNU
findapply tests and actions at exactly depthN?ਜਵਾਬ
-mindepth N -maxdepth N. Both bounds includeN, so only that level is eligible.ਕਾਰਡ 10
ਸਵਾਲ
Which paths does GNU
findprint, in any order?studio/ ├── .theme ├── sketch └── drafts/ └── notesfind studio -maxdepth 1 -type f -printਜਵਾਬ
studio/.theme studio/sketchA leading dot does not change depth or file type.
draftsis a directory, andnotesis too deep.ਕਾਰਡ 11
ਸਵਾਲ
Which paths does GNU
findprint, in any order?inbox/ ├── notice.txt └── reports/ └── weekly.txtfind inbox -mindepth 2 -type f -printਜਵਾਬ
inbox/reports/weekly.txtGNU
findpasses throughreportsat depth 1 and tests its child at depth 2.ਕਾਰਡ 12
ਸਵਾਲ
Which paths does GNU
findprint, in any order?museum/ ├── audio.mp3 └── west/ └── hall/find museum -maxdepth 1 -type d -printਜਵਾਬ
museum museum/westBoth directories fall within depths 0 and 1.
-type dselects directories.ਕਾਰਡ 13
ਸਵਾਲ
Which paths does GNU
findprint, in any order?camp/ ├── water └── trail/ ├── fork/ │ └── marker └── signfind camp -mindepth 2 -maxdepth 2 -printਜਵਾਬ
camp/trail/fork camp/trail/signBoth entries are at depth 2. Directories and regular files can both print at that level.
ਕਾਰਡ 14
ਸਵਾਲ
Which GNU
finddepth options select depths 2 through 4, including both ends?ਜਵਾਬ
-mindepth 2 -maxdepth 4. The eligible depths are 2, 3 and 4.ਕਾਰਡ 15
ਸਵਾਲ
Which paths does GNU
findprint, in any order?desk/ └── lamp rack/ └── shelf/ └── boxfind desk rack -mindepth 1 -maxdepth 1 -printਜਵਾਬ
desk/lamp rack/shelfGNU
findcounts depth separately fromdeskand fromrack.ਕਾਰਡ 16
ਸਵਾਲ
archiveis a directory. What does this GNUfindcommand print?find archive -mindepth 3 -maxdepth 1 -printਜਵਾਬ
No paths print. No depth satisfies both bounds.
ਕਾਰਡ 17
ਸਵਾਲ
Using GNU
find, list the regular files directly insideserverwhose names end in.log.ਜਵਾਬ
find server -maxdepth 1 -type f -name '*.log' -printThe cap reaches direct children.
-type fexcludes the starting directory, and the quotes pass*.logto GNUfindas a pattern.ਕਾਰਡ 18
ਸਵਾਲ
This GNU
findcommand printspartsitself. Which option would you add to keep only its direct children?find parts -maxdepth 1 -printਜਵਾਬ
Add
-mindepth 1. With-maxdepth 1, that leaves exactly depth 1.ਕਾਰਡ 19
ਸਵਾਲ
GNU
findstarts at bothdepotanddepot/aisle. What is the depth ofdepot/aisle/binin each search?ਜਵਾਬ
Depth 2 from
depotand depth 1 fromdepot/aisle. Each starting point has its own depth 0.ਕਾਰਡ 20
ਸਵਾਲ
printshopis a directory containing jobs. What does this GNUfindcommand print?find printshop -maxdepth 0 -printਜਵਾਬ
printshop. The cap is 0, so GNUfindevaluates only the starting point.ਕਾਰਡ 21
ਸਵਾਲ
Which paths does GNU
findprint, in any order?bakery/ └── bin/ └── tray/ └── box/ └── tagfind bakery -mindepth 2 -maxdepth 3 -printਜਵਾਬ
bakery/bin/tray bakery/bin/tray/boxThe two bounds include depths 2 and 3.
ਕਾਰਡ 22
ਸਵਾਲ
Using GNU
find, list only the directories immediately insidemusic.ਜਵਾਬ
find music -mindepth 1 -maxdepth 1 -type d -printDepth 1 selects direct children.
-type dkeeps directories among those children.ਕਾਰਡ 23
ਸਵਾਲ
Which paths does this GNU
findcommand print, in any order?project/ ├── cache/ │ └── token └── src/ └── indexfind project -path 'project/cache' -prune -o -printਜਵਾਬ
project project/src project/src/indexAt
project/cache,-prunestops descent and the successful left side of-oskips-print.ਕਾਰਡ 24
ਸਵਾਲ
Which paths does GNU
findprint, in any order?shelf/ ├── .spare/ │ └── screw └── tin/ └── washerfind shelf -mindepth 2 -maxdepth 2 -type f -printਜਵਾਬ
shelf/.spare/screw shelf/tin/washerGNU
findalso descends through dot-prefixed directories. Both files are two levels fromshelf.ਕਾਰਡ 25
ਸਵਾਲ
GNU
findstarts atmarket/stalls. Which depth options select just the direct children of that starting point?ਜਵਾਬ
-mindepth 1 -maxdepth 1. The full starting pathmarket/stallsis at depth 0.ਕਾਰਡ 26
ਸਵਾਲ
Using GNU
find, list every entry at depth 3 or deeper withlibraryas the starting point.ਜਵਾਬ
find library -mindepth 3 -printTests and actions start at depth 3. Omitting
-maxdepthleaves deeper entries eligible.ਕਾਰਡ 27
ਸਵਾਲ
Does this GNU
findcommand prunebuild/cache, a directory directly underbuild?find build -mindepth 2 -path 'build/cache' -prune -o -printਜਵਾਬ
No.
build/cacheis at depth 1, where-mindepth 2skips the tests and actions. GNUfindcan descend into it.ਕਾਰਡ 28
ਸਵਾਲ
logs/ready/worker.logis a regular file, but this GNUfindcommand misses it. What smallest change to the depth cap makes it eligible?find logs -maxdepth 1 -type f -name '*.log' -printਜਵਾਬ
Change
-maxdepth 1to-maxdepth 2.worker.logsits two levels belowlogs.
28 ਕਾਰਡ
GNU find Depth Flashcards: -maxdepth and -mindepth
ਪੜ੍ਹਾਈ ਸ਼ੁਰੂ ਕਰਨ ਲਈ Nibomo ਖੁੱਲ੍ਹੇਗਾ।