My effort is to use a piece of code in my program to find and copy certain files in my system.
The code I wrote meant to do that is:
void scan(int i)
{
pid_t parent = getpid();
pid_t pid = fork();
if (pid == -1)
{
cout << "failed to fork" << endl;
return;
}
else
{
if(pid > 0)
{
int status;
waitpid(pid, &status, 0);
}
else
{
if(i == 0)
{
execl("/usr/bin/find","find", "/", "-name", "'*.mp3'","-exec","cp","{}","/home/pi/Music","\\;",(char *)0);
_exit(EXIT_FAILURE);
}
}
}
return; }
Nevertheless, the system returns this:
find: missing argument to `-exec'
How exactly can I correct my execl command to execute this shell command:
find / -name '*.mp3' -exec cp {} /home/pi/Music \;