mirror of https://github.com/sharkdp/fd.git
Update documentation for --exec syntax change
This commit is contained in:
parent
0f82fe7ec0
commit
5f4a1203b4
|
@ -110,14 +110,17 @@ commands is similar to that of GNU Parallel:
|
|||
- `{/.}`: Uses the basename, with the extension removed (`party`).
|
||||
|
||||
``` bash
|
||||
# Convert all jpg files to png files
|
||||
fd -e jpg -x 'convert {} {.}.png'
|
||||
# Convert all jpg files to png files:
|
||||
fd -e jpg -x convert {} {.}.png
|
||||
|
||||
# Unpack all zip files (if no placeholder is given, the path is appended):
|
||||
fd -e zip -x unzip
|
||||
|
||||
# Convert all flac files into opus files:
|
||||
fd -e flac -x 'ffmpeg -i {} -c:a libopus {.}.opus'
|
||||
fd -e flac -x ffmpeg -i {} -c:a libopus {.}.opus
|
||||
|
||||
# Count the number of lines in Rust files (the command template can be terminated with ';'):
|
||||
fd -x wc -l \; -e rs
|
||||
```
|
||||
|
||||
## Install
|
||||
|
|
14
doc/fd.1
14
doc/fd.1
|
@ -101,21 +101,21 @@ Always colorize output.
|
|||
.BI "\-j, \-\-threads " num
|
||||
Number of threads to use for searching (default: number of available CPUs).
|
||||
.TP
|
||||
.BI "\-x, \-\-exec " command
|
||||
.BI "\-x, \-\-exec " command [args...] ;
|
||||
Execute
|
||||
.I command
|
||||
on each of the discovered path with the following tokens substituted:
|
||||
for each search result. The following placeholders are substituted by a path derived from the current search result:
|
||||
.RS
|
||||
.IP {}
|
||||
path
|
||||
.IP {.}
|
||||
path without extension
|
||||
.IP {/}
|
||||
basename of path
|
||||
basename
|
||||
.IP {//}
|
||||
parent of path
|
||||
parent directory
|
||||
.IP {.}
|
||||
path without file extension
|
||||
.IP {/.}
|
||||
basename of path without extension
|
||||
basename without file extension
|
||||
.RE
|
||||
.SH ENVIRONMENT
|
||||
.TP
|
||||
|
|
21
src/app.rs
21
src/app.rs
|
@ -86,6 +86,7 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
.long("exec")
|
||||
.short("x")
|
||||
.multiple(true)
|
||||
.min_values(1)
|
||||
.allow_hyphen_values(true)
|
||||
.value_terminator(";")
|
||||
.value_name("cmd"),
|
||||
|
@ -173,15 +174,17 @@ fn usage() -> HashMap<&'static str, Help> {
|
|||
, "Filter by file extension"
|
||||
, "(Additionally) filter search results by their file extension.");
|
||||
doc!(h, "exec"
|
||||
, "Execute the given command for each search result"
|
||||
, "Execute the given command for each search result.\n\
|
||||
The following are valid tokens that can be used within the expression for generating \
|
||||
commands:\n \
|
||||
'{}': places the input in the location of this token\n \
|
||||
'{.}': removes the extension from the input\n \
|
||||
'{/}': places the basename of the input\n \
|
||||
'{//}': places the parent of the input\n \
|
||||
'{/.}': places the basename of the input, without the extension");
|
||||
, "Execute a command for each search result"
|
||||
, "Execute a command for each search result.\n\
|
||||
All arguments following -exec are are taken to be arguments to the command until the \
|
||||
argument ';' is encountered.\n\
|
||||
Each occurrence of the following placeholders is substituted by a path derived from the \
|
||||
current search result before the command is executed:\n \
|
||||
'{}': path\n \
|
||||
'{/}': basename\n \
|
||||
'{//}': parent directory\n \
|
||||
'{.}': path without file extension\n \
|
||||
'{/.}': basename without file extension");
|
||||
doc!(h, "exclude"
|
||||
, "Exclude entries that match the given glob pattern."
|
||||
, "Exclude files/directories that match the given glob pattern. This overrides any \
|
||||
|
|
Loading…
Reference in New Issue