diff --git a/README.md b/README.md index 36cce2ab2..43ee4fe02 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,7 @@ Options: executable (x), empty (e), socket (s), pipe (p), block-device (b), char-device (c) -e, --extension Filter by file extension + --inum Filter by inode number -S, --size Limit results based on the size of files --changed-within Filter by file modification time (newer than) --changed-before Filter by file modification time (older than) diff --git a/doc/fd.1 b/doc/fd.1 index 23ce2f44c..ec98df242 100644 --- a/doc/fd.1 +++ b/doc/fd.1 @@ -271,6 +271,9 @@ Always colorize output. .BI "\-j, \-\-threads " num Set number of threads to use for searching & executing (default: number of available CPU cores). .TP +.BI "\-\-inum " num +Filter files by their inode number. +.TP .BI "\-S, \-\-size " size Limit results based on the size of files using the format .I <+-> diff --git a/src/cli.rs b/src/cli.rs index 43daa995d..1f37a52f8 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -375,6 +375,20 @@ pub struct Opts { )] pub extensions: Option>, + /// Filter files by their inode number. + /// Format: [inum]. + /// + /// Examples: + /// {n} --inum 4242 + #[cfg(unix)] + #[arg( + long, + value_name = "inode-number", + help = "Filter by inode number", + long_help + )] + pub inum: Option, + /// Limit results based on the size of files using the format <+->. /// '+': file size must be greater than or equal to this /// '-': file size must be less than or equal to this diff --git a/src/config.rs b/src/config.rs index d0a2fd209..03b6a7241 100644 --- a/src/config.rs +++ b/src/config.rs @@ -47,6 +47,10 @@ pub struct Config { /// Whether elements of output should be separated by a null character pub null_separator: bool, + #[cfg(unix)] + /// The inode number to search for. + pub inode_number: Option, + /// The maximum search depth, or `None` if no maximum search depth should be set. /// /// A depth of `1` includes all files under the current directory, a depth of `2` also includes diff --git a/src/main.rs b/src/main.rs index 764b7e340..eb5fc14ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -206,6 +206,8 @@ fn construct_config(mut opts: Opts, pattern_regexps: &[String]) -> Result Result