File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,6 +189,12 @@ fd -e h -e cpp -x clang-format -i
189189Note how the ` -i ` option to ` clang-format ` can be passed as a separate argument. This is why
190190we put the ` -x ` option last.
191191
192+ Any positional arguments after ` -x ` belong to the command template, not to ` fd ` itself. If you
193+ also want to pass a pattern or search path, put ` -x ` last:
194+ ``` bash
195+ fd pattern path -x echo
196+ ```
197+
192198Find all ` test_*.py ` files and open them in your favorite editor:
193199``` bash
194200fd -g ' test_*.py' -X vim
@@ -228,6 +234,9 @@ fd -tf -x md5sum > file_checksums.txt
228234The ` -x ` and ` -X ` options take a * command template* as a series of arguments (instead of a single string).
229235If you want to add additional options to ` fd ` after the command template, you can terminate it with a ` \; ` .
230236
237+ For example, ` fd -x echo \; pattern path ` treats ` pattern path ` as ` fd ` arguments instead of
238+ passing them to ` echo ` . In practice, it is often clearer to write ` fd pattern path -x echo ` .
239+
231240The syntax for generating commands is similar to that of [ GNU Parallel] ( https://www.gnu.org/software/parallel/ ) :
232241
233242- ` {} ` : A placeholder token that will be replaced with the path of the search result
Original file line number Diff line number Diff line change @@ -872,7 +872,8 @@ impl clap::Args for Exec {
872872 "Execute a command for each search result in parallel (use --threads=1 for sequential command execution). \
873873 There is no guarantee of the order commands are executed in, and the order should not be depended upon. \
874874 All positional arguments following --exec are considered to be arguments to the command - not to fd. \
875- It is therefore recommended to place the '-x'/'--exec' option last.\n \
875+ It is therefore recommended to place the '-x'/'--exec' option last. \
876+ Use '\\ ;' to terminate the command template if you need to continue passing fd arguments afterwards.\n \
876877 The following placeholders are substituted before the command is executed:\n \
877878 '{}': path (of the current search result)\n \
878879 '{/}': basename\n \
@@ -887,6 +888,8 @@ impl clap::Args for Exec {
887888 fd -e zip -x unzip\n \n \
888889 - find *.h and *.cpp files and run \" clang-format -i ..\" for each of them:\n \n \
889890 fd -e h -e cpp -x clang-format -i\n \n \
891+ - search within `src/` and echo each match (place `-x` last):\n \n \
892+ fd . src -x echo\n \n \
890893 - Convert all *.jpg files to *.png files:\n \n \
891894 fd -e jpg -x convert {} {.}.png\
892895 ",
You can’t perform that action at this time.
0 commit comments