>_ IzzyLab

Hands-on task

This task is step 1 of the course “find and xargs: search and bulk operations”

find: files by name

easy~5 min

In the tree /root/tree find all regular files with the .conf extension (at any depth) and write their full paths (starting with /root/tree), sorted, to /root/found.txt. Directories and files with a different extension must not get into the list.

What you'll practise:
  • find
  • search by name
  • glob patterns
  • sort
  • recursive traversal

Topic breakdown

find is a recursive tree-walking engine: the first argument sets the starting point, then you stack up predicate filters. Selection by name is done with a predicate using a glob pattern, and the pattern must be quoted, otherwise the shell expands it itself before find even runs. find doesn't guarantee output order, so for a reproducible result it's piped through sort.

What's checked

  1. the file /root/found.txt is created
  2. the list has no directories
  3. the list has no files with another extension
  4. all .conf files are found, with full paths, sorted

What it looks like