Reminder on how to use -exec
action in GnuWin32 find command in Windows cmd.exe. For example, if you want to find a string, the format is:
find . -type f -exec grep <pattern> {} ;
If you do any of the following, you can get this cryptic error message: find: missing argument to `-exec'
- Put double-quote marks around the command:
find . -type f -exec "grep <pattern> {} ;"
- Don't leave a space between braces and semi-colon:
find . -type f -exec "grep <pattern> {};"
- Use Unix shell escape character:
find . -type f -exec grep <pattern> {} \;
Finally, if all else fails and you lack time to investigate, use xargs:
find . -type f | xargs grep <pattern>
Thank you. This is very helpful.
ReplyDeleteVery helpful. right on the money.
ReplyDeletethank you!
ReplyDeleteThank you!!
ReplyDeleteExcellent, very well explained
ReplyDeletei love you, just spent an hour trying to sort this
ReplyDeletetry also:
ReplyDeletefind . -type f -exec grep pattern "{}" ";"