Skip to main content

High-Performance Find

If the JuiceFS file system contains a large number of files and needs to search by specific criteria, the built-in find command in Linux may have poor performance. Since v5.3.7, you can use juicefs find as a high-performance alternative to find, typically 10-100 times faster. We aim to support all usages that find supports in juicefs find.

Feature overview

The juicefs find command recursively searches for files or directories in JuiceFS mount points based on conditions and supports executing actions, such as printing, deleting, or executing external commands.

The implementation uses two-stage filtering:

  • Server-side filtering (metadata side): Quickly filters using an expression abstract syntax tree (AST) on the metadata tree to reduce data volume returned.
  • Client-side filtering and action execution (mount side): Perform final expression evaluation on entries returned by the server and execute actions. The default action is -print.

Command format

juicefs find [PATH ...] [EXPRESSION]

Simple examples:

juicefs find /mnt/jfs -name "*.log"
juicefs find /mnt/jfs -type f -size +10M -print
juicefs find /mnt/jfs -name "*.tmp" -a -delete
juicefs find /mnt/jfs -type f -exec ls -l {} \;

Advanced usage examples:

# Find large files
juicefs find /mnt/jfs -type f -size +1G

# Find logs modified within the last day
juicefs find /mnt/jfs -name "*.log" -mtime -1

# Find path with case-insensitive matching
juicefs find /mnt/jfs -ipath "*backup*"

# Combine conditions
juicefs find /mnt/jfs -type f -a \( -name "*.go" -o -name "*.md" \)

# Execute actions
juicefs find /mnt/jfs -type f -name "*.tmp" -delete
juicefs find /mnt/jfs -type f -name "*.log" -exec gzip {} \;

Options and syntax

Traversal options:

  • -p, --threads N Concurrency parameter (recommended to use -p first in the current implementation)
  • -maxdepth N: Maximum traversal depth
  • -mindepth N: Minimum matching depth

Logical operators:

  • AND: -a, -and (implicit AND also supported)
  • OR: -o, -or
  • NOT: !, -not
  • Grouping: (...)

Expressions follow standard operator precedence (highest to lowest):

  1. Parentheses
  2. NOT
  3. AND
  4. OR

Supported predicates:

  • Name and path: -name, -iname, -path, -ipath
  • Regular expression: -regex, -iregex
  • Type: -type (f|d|l)
  • Size: -size [+|-]N[KMGT]
  • Time: -mtime, -atime, -ctime, -mmin, -amin, -cmin, -newer, -anewer, -cnewer, -newerXY
  • Others: -empty, -links, -inum, -perm, -user, -group, -nouser, -nogroup

Supported actions:

  • -print: This is the default action when no action is explicitly provided.
  • -print0
  • -exec CMD {} \;: Currently does not support the -exec ... + form.
  • -delete