Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verbose flag to delete found matches #253

Closed
BrainMaestro opened this issue Mar 7, 2018 · 5 comments
Closed

Verbose flag to delete found matches #253

BrainMaestro opened this issue Mar 7, 2018 · 5 comments
Labels

Comments

@BrainMaestro
Copy link

Hi @sharkdp. Thanks for the awesome project.

Some common uses of find is to delete files that match the pattern. This is so common that find has a -delete flag. I know it can be accomplished with --exec rm {} \+, but it would be nice to save some keystrokes. What do you think? I wouldn't mind trying to implement it if you point me in the right direction. I'm not yet very familiar with Rust though.

@sharkdp
Copy link
Owner

sharkdp commented Mar 8, 2018

Thank you for the feedback!

If this is mainly about saving keystrokes, note that you can skip the {} part, (I'm not sure what the + part does.. enabe verbose mode?) since fd will attach the path by default. You can also shorten --exec to -x, to get:

fd ... -x rm

or

fd ... -x rm -v

for verbose mode.

@BrainMaestro
Copy link
Author

Oh. I forgot about the -x and it's nice that {} can be skipped.

+ basically makes exec behave like xargs.
man page

-exec command {} +
This variant of the -exec action runs the specified command on the selected files, but the command line is built by appending each selected file name at the end; the total number of invocations of the command will be much less than the number of matched files. The command line is built in much the same way that xargs builds its command lines. Only one instance of '{}' is allowed within the command. The command is executed in the starting directory.

Maybe that's the more interesting feature to implement

@sharkdp
Copy link
Owner

sharkdp commented Mar 12, 2018

Oh right, that was a find feature, not a rm-argument. Note that fd runs commands in parallel, so there is probably a little less need for that feature.

@BrainMaestro
Copy link
Author

yes, I know that's a find feature. That excerpt is from the find man page. I'm just saying that maybe it would be useful to implement that in fd. There might be cases where you would not want the parallel behaviour.

@lnicola
Copy link

lnicola commented May 22, 2019

👍 for adding a --delete parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants