1
1
123qwe2015-11-08 12:03:34
linux
123qwe, 2015-11-08 12:03:34

How to delete files with the same extension in a specific folder on Unix-like?

What is even up, programmer.
find. -type f -name '*.jpg' -exec rm {} +
Here is the command that worked for me.
I needed to delete all files with the appropriate extension in the directory that I was, but this command is not logically clear to me. There is something more logically clear, like ". rm -a ".jpg"
And yes, if this command is nevertheless good, then explain it sequentially.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
sunrails, 2015-11-08
@Yonghwa

Find: find
Where? In current directory: .
What? Files: -type f
Everything in a row? No, according to the pattern: -name '*.jpg'
What to do with the result? Divide the result into groups and call the rm command for each group, where {} + is a group of files: -exec rm {} +

R
Ruslan Fedoseev, 2015-11-08
@martin74ua

have you read man find?

T
Thomas Storm, 2015-11-08
@v_sadist

I'm sorry, why didn't you use the command?
rm /path/to/dir/*.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question