Безусловно, самый безопасный и простой способ сделать это - использовать опцию find -exec . От man find:
-exec utility [argument ...] ;
     True if the program named utility returns a zero value as its exit status.
     Optional arguments may be passed to the utility.  The expression must be 
     terminated by a semicolon (``;'').  If you invoke find from a shell you 
     may need to quote the semicolon if the shell would otherwise treat it as a 
     control operator.  If the string ``{}'' appears anywhere in the utility 
     name or the arguments it is replaced by the pathname of the current file.  
     Utility will be executed from the directory from which find was executed.  
     Utility and arguments are not subject to the further expansion of shell 
     patterns and constructs.
-exec utility [argument ...] {} +
     Same as -exec, except that ``{}'' is replaced with as many pathnames as 
     possible for each invo-cation invocationcation of utility. This behaviour 
     is similar to that of xargs(1).
Другими словами, опция -exec будет запускать все, что вы дадите ей по результатам поиска, заменяя {} на каждый найденный файл (или каталог). Итак, чтобы выполнить поиск определенной строки, вы должны сделать:
find src/main -name "*" -exec grep -i 'mystring' {} +
Это, однако, также найдет каталоги и выдаст ошибку. Имейте в виду, что он будет работать, он просто будет жаловаться, когда вы попытаетесь запустить его в каталоге, у вас возникла бы та же проблема с использованием xargs . То, что вы на самом деле пытаетесь сделать здесь, это найти все файлы и только файлы. В этом случае -name '*' не требуется, поскольку find src/main точно такой же, как find src/main -name "*" . Таким образом, вместо того, чтобы использовать это, укажите, что вы хотите только найти файлы:
find src/main -type f -exec grep -i 'mystring' {} +