I found the following line here:
find * -maxdepth 0 -type d -exec tar czvf {}.tar.gz {} \; \;
It is meant to tar gzip each folder in the current directory individually. But running it returns the error:
find: paths must precede expression:
There are a few posts on this error, but they don't relate to the syntax used here.
Does anyone know what is causing this error?
{}
in an-exec
expression is expanded (byfind
, not by the shell) to the name of each file found. Seeman find
for details. (It's common to see\{\}
or'{}'
. In some expressions,{}
has to be quoted to prevent actual or attempted shell expansion of it before it's passed tofind
. But{}
doesn't need to be quoted as it's used in this question. For example,find . -maxdepth 1 -exec echo {}.blah \;
works fine frombash
.) As muru says, the problem here is instead the extra\;
.