I run this command:
~/shell_temp$ find . -type f -name "IMAG1806.jpg" -exec rm -f {}\
i got output below:
> IMAG1806.jpg
Error:
find: missing argument to `-exec'
what is exact command for find any file from current directory and remove with -exec
?
Best Answer
You missed the a
;
at the end (and a space too between{}
and;
). The correct command is:;
indicates the end of-exec
predicate offind
.Also note that we have used
\;
i.e.\
in front of;
to escape the interpretation of;
by shell, otherwise shell will treat;
as end of the wholefind
command andfind
will throw the same error. You can also use';'
instead of\;
.You were using
\
at the end, this indicates your shell will continue to take input viaPS2
(indicated by>
), you typedIMAG1806.jpg
again, so the whole command becomes:As you can see this is not a valid command at all with
IMAG1806.jpg
at the end, no closing of-exec
predicate and without a space between{}
and\;
.