FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next 

Finding files


The find command searches for files in the filesystem by name, owner, size, date, ... The format of the find command is:
    find [path...] [expression]
where path is the starting point for the search and expression can be a set of options, tests and actions. Some of the tests:



  1. Find a file named vtree.tgz.
  2. Find all files with the filename alterego.
  3. Find all files that belong to floopy.
  4. Find all empty files in the /etc directory.
  5. Find all files under the /etc directory with a filename that starts with K (in uppercase).
  6. Find all directories starting in /var.
  7. Find a file named penguin.
  8. Find all files (not directories) that start with "p".
  9. Find all files that end with ".gz".
  10. Find everything that belongs to the mail group.

Questions & Answers:

  1. What command will find all filenames ending in .html?
    Answer: find / -name *.html
  2. What command will find all files belonging to alterego?
    Answer: find / -user alterego
  3. What command will find a directory named netlp starting in the /var directory?
    Answer: find /var -type d -name netlp
  4. What command will suppress the display of the "permission denied" messages that are displayed when you use the find command?
    Answer: find / -name penguin 2> /dev/null
  5. What command will find all empty directories (use man to lookup options for the find command).
    Answer: find / -type d -empty

Copyright © L. M. MacEwan
FLOPPIX Home | FAQ | Download | Labs | ToC | Back |  Next