CyberStars

find Filters

find -name matches by name. But find can filter by other properties too, most usefully by type and size.

Filter by type: -type

The -type option says whether you want files or directories:

ConditionMatches
-type fregular files
-type ddirectories
find . -type d

That lists every folder under .. To find only files:

find . -type f -name "*.log"

This reads as: under ., find things that are files and whose name ends in .log. Multiple conditions are simply listed one after another: find requires all of them to match.

Filter by size: -size

The -size option matches files by how big they are:

ExampleMatches
-size +1kbigger than 1 kilobyte
-size -1ksmaller than 1 kilobyte
-size +1Mbigger than 1 megabyte

A + means "more than", a - means "less than". The letter is the unit (k, M, G).

find . -type f -size +1k

That finds every file larger than 1 KB.


Mission: Station Directory Scan

The chief engineer needs a structural overview of the station folder before reorganising the file system, and the text notes gathered in one place.

  1. List only the directories inside station.
  2. List only the .txt files inside station (files, not folders).
  3. Gather the text notes you found: create a folder called txt-index and copy station/notes.txt and station/bay/manifest.txt into it.

Expected result

You see the directory paths, then the .txt file paths, and the txt-index folder holds copies of both text notes.