find: Overview
1
1 1.2 Overview
1 ============
1
1 The principal programs used for making lists of files that match given
1 criteria and running commands on them are 'find', 'locate', and 'xargs'.
1 An additional command, 'updatedb', is used by system administrators to
1 create databases for 'locate' to use.
1
1 'find' searches for files in a directory hierarchy and prints
1 information about the files it found. It is run like this:
1
1 find [FILE...] [EXPRESSION]
1
1 Here is a typical use of 'find'. This example prints the names of all
1 files in the directory tree rooted in '/usr/src' whose name ends with
1 '.c' and that are larger than 100 Kilobytes.
1 find /usr/src -name '*.c' -size +100k -print
1
1 Notice that the wildcard must be enclosed in quotes in order to
1 protect it from expansion by the shell.
1
1 'locate' searches special file name databases for file names that
1 match patterns. The system administrator runs the 'updatedb' program to
1 create the databases. 'locate' is run like this:
1
1 locate [OPTION...] PATTERN...
1
1 This example prints the names of all files in the default file name
1 database whose name ends with 'Makefile' or 'makefile'. Which file
1 names are stored in the database depends on how the system administrator
1 ran 'updatedb'.
1 locate '*[Mm]akefile'
1
1 The name 'xargs', pronounced EX-args, means "combine arguments."
1 'xargs' builds and executes command lines by gathering together
1 arguments it reads on the standard input. Most often, these arguments
1 are lists of file names generated by 'find'. 'xargs' is run like this:
1
1 xargs [OPTION...] [COMMAND [INITIAL-ARGUMENTS]]
1
1 The following command searches the files listed in the file 'file-list'
1 and prints all of the lines in them that contain the word 'typedef'.
1 xargs grep typedef < file-list
1