In my git project I need to remove all files ending with **.pyc. I therefore run the below command, but got this error of no terminating ";"
that I do not understand what it means.
find . -name "**.pyc" -exec git rm {};
find: -exec: no terminating ";" or " "
If I just run find . -name "**.pyc"
I get a list of all files of format .pyc.
CodePudding user response:
When you execute find . -name "**.pyc" -exec git rm {};
, the shell reads the ;
as a terminating character and executes the command find . -name "**.pyc" -exec git rm {}
. But this is an error, because find
expects the -exec
command to be terminated by a ;
. That is, you need to pass ;
as one of the arguments to find
. You accomplish that by escaping it to the shell, either with find . -name "**.pyc" -exec git rm {} \;
or find . -name "**.pyc" -exec git rm {} ";"
Another option is to terminate the -exec
with
, which will invoke git rm
with more than one argument, resulting in fewer invocations of git
. This is slightly more convenient, since
does not need to be escaped.