Small update for the tutorial
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by sharkdp · committed by sharkdp · parent 0cd9d8c · Browse files · 1 file·+5 added−25 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+5 added−25 removed
- other:+5 added−25 removed
Provenance
- Commit
b9b6964- Tree
ec6ef6f- Author
sharkdp <davidpeter@web.de>- Committer
sharkdp <davidpeter@web.de>- Parent
0cd9d8c
1 file changed+5 added−25 removed
modified:README.md+5 added-25 removed
213 unmodified lines214 this_is_a_test215 ```216 217 The search pattern is treated as a regular expression. To show only entries that start with "test",218-we can simply run:218+we can call:219 ```220 > fd '^test'221 sub_dir/more_dir/even_further_down/test_seven222 sub_dir/more_dir/even_further_down/testing_eight79 unmodified lines302 sub_dir/more_dir/even_further_down/not_me.sh303 sub_dir/more_dir/not_file304 ```305 306-Searching for a file extension is easy too, using the `-e` (or `--file-extensions`) switch for file306+Searching for a file extension is easy too, using the `-e` (or `--extension`) switch for file307 extensions:308 ```309 > fd -e sh310 sub_dir/more_dir/even_further_down/not_me.sh6 unmodified lines317 fd_examples/desub_dir/old_test.txt318 fd_examples/sub_dir/new_test.txt319 ```320 321-What if we wanted to run a command for each of the search results? We can use `xargs` to do that:322-`fd -0 'test' | xargs -0 -I {} cp {} {}.new`323-324-In this example there are a couple things to take note:325- - First we are telling `fd` we want a null character to seperate the files `-0`, this is326- important when passing to `xargs`.327- - Second, we are piping the output to `xargs` and telling this program to expect input null328- terminated with `-0` (the same syntax that `fd` was built with).329- - Then for fun we are using `-I` to replace a string `{}` and lauching `cp` to copy the file `{}`330- to a file ending in `{}.new`.331-332-`fd` can also show us the absolute path vs. the full path with `-a` (`--absolute-path`):321+If we want to run a command for each of the search results, we can use the `-0` option to pipe322+the output to `xargs`:323 ```334-> fd -a new335-/Users/fd_user/fd_examples/sub_dir/more_dir/even_further_down/test_seven.new336-/Users/fd_user/fd_examples/sub_dir/more_dir/even_further_down/testing_eight.new337-/Users/fd_user/fd_examples/sub_dir/more_dir/test_file_six.new338-/Users/fd_user/fd_examples/sub_dir/test_file_five.new339-/Users/fd_user/fd_examples/sub_dir/test_file_four.new340-/Users/fd_user/fd_examples/sub_dir/test_file_three.new341-/Users/fd_user/fd_examples/test_file_one.new342-/Users/fd_user/fd_examples/test_file_two.new343-/Users/fd_user/fd_examples/test_one.new344-/Users/fd_user/fd_examples/this_is_a_test.new324+> fd -0 'test' | xargs -0 wc -l325 ```