• Home
  • Docker
  • Kubernetes
  • LLMs
  • Java
  • Ubuntu
  • Maven
  • Big Data
  • Archived
Linux-Ubuntu | find -- search files/directories
  1. Notes
  2. Examples
  3. Command Help (man find)
  4. Possible values of find options

  1. Notes

    You might want to ignore access permission errors and redirect them to /dev/null by using the STDERR redirection operator:

    To filter out the search result, you can use the following options: -or, -o, -and, -not
    To combine these options and form an expression, you can use the following syntax: \( expression \) (note the space before and after the expression)





    You can execute a command on the search result by using the following options: -exec, -ok
    The -exec option executes the command on each file found (or directory), without asking for confirmation.
    The -ok option ask for confirmation before executing the command on each file found (or directory). You can confirm the execution of the command by typing y and pressing Enter otherwise press Enter to skip the execution of the command.

    The syntax for both options is as following:


    Notice the use of the curly braces that act as a place holder for the found file name (or directory).
    The command line should end with a semicolon (;) or a plus (+) character.
    The semicolon (;) character force the execution of the command for each found file.
    The plus (+) character allow the execution of the command on a group of found files.

    The semicolon (;) character should be escaped with backslash character (\) to avoid that shell interpret the semicolon as a special character (shell commands separator). You can also escape the semicolon (;) character by putting it within double quotes (";") or single quotes (';'). You might also want to escape the plus (+) character with backslash character (\).


  2. Examples
    • Search files:

    • Search directories:

    • Search files/directories with a specific name:

      • Search files with a specific name:
      • Search directories with a specific name:
      • Search files whose names do not end with .c:
      • Search files/directories which are not both files and their names end with .c:
      • Search files/directories which are either directories or that their names end with .c:
    • Search files/directories where the name of the file/directory contain a specific pattern:

      • Search files where the name of the file contain a specific pattern:
      • Search directories where the name of the directory contain a specific pattern:
    • Search files that contain a specific word:

    • Search files and use the "-exec" command to execute specific commands:

      • Search files where the name of the file contain a specific pattern:
      • Search files inside jar files:
      • Search files inside jar files:
    • Search and delete files/directories:

    • Search files and replace text within these files:

      mac users (OS X):
    • Search and rename directories:

    • Clean-up an eclipse project:
  3. Command Help (man find)
    The following options can be used:
    • To search files by type/name/path, use the following options:

    • To search files by time, use the following options:

    • To search files by size, use the following options:

    • To search files by user/group, use the following options:

    • The following options can be used to execute specific actions:

    • The following operators (listed in order of decreasing precedence) can be combined with options:
  4. Possible values of find options
    • All options that take a numeric argument (n) allow the number to be preceded by a plus sign (+) or a minus sign (-):

    • Possible time units [smhdw] are as follows:

    • Possible size units [ckMGTP] are as follows:

    • Possible file types are as follows:
© 2025  mtitek