I'm running GNU find in a QProcess which works just fine. Nevertheless, when I try to combine it with grep, it does not execute at all.
The QProcess is started with
process->start(findpattern.replace("~",QDir::home().absolutePath()), QProcess::Unbuffered | QProcess::ReadWrite);
When findpattern is e.g.
find "~/Downloads" -name "*.cpp"
this works just fine. But for e.g. finding all cpp files that contain "else"
find "~/Downloads" -name "*.cpp" -exec grep -l "else" {} \;
it fails
What am I doing wrong?
The purpose of the backslash in
{} \;
is that the shell doesn't interpret the semicolon as a separator to the next command. This backslash will be removed by the shell and not passed tofind
.But
QProcess
runsfind
directly, not through a shell, so that backslash should not be there.From find's manpage: