That’s maybe some common Error you’re receiving, when you’re new to find and the exec parameter. So I encountered the Problem as well.
After a short research within the man page of find the problem was found: ‘;‘ needs to be escaped with a Backslash ‘\‘. The look over to my commandline just showed that this was already the case. Now the internet was asked and most results just reveal the same thing: escape the ; with a Backslash.
Some hits later I found a german page where they told that it’s even required that the ‘\;‘ is separated from the previous commands with a space ‘ \;‘. So it’s not enough to write -exec command ‘{}\;‘ it needs to be -exec command ‘{} \;‘ . Well from my point of view some mistake which can be fast overseen, even more if you suppose that ‘{}\;‘ should work out nicely as it’s something which occurs often or everytime within the exec(at least these groups of signs).
Just something new learnt, and hopefully for a few people less headache.
Tags: -exec, find
Entries (RSS)
Thanks. It helped me today.
Thanks dude. Was looking for a solution!
Thank you so much for your help. i’ve been working on a script to delete files in a hom directory and have been messing with this for about 2 hours. This statement very picky with the sytax. here is what worked for me.
sudo find /home/test -mtime +2 -exec rm -f {} \;