My program needs to find and delete a file and print out a specific message every time it does. Right now I am using:
system("find -name find_me.txt -delete 2>//dev//null");
The problem is this doesn't actually print anything out. What I have done is:
system("find -name find_me.txt 2>//dev//null 1>result.txt");
system("find -name find_me.txt -delete 2>//dev//null");
and I just print out "fine_me.txt was deleted" for every line in result.txt. There HAS to be a better way to do this! Any ideas? Unfortunately find returns 0 if all files are scanned correctly so I can't just print out a message based on this. I would really rather not write my own search and delete function. The problem with my implementation is if it finds a file that it can't delete it's going to print out a message for it because a line is added for every file found, whether you can delete it or not. Thanks in advance. I tried googling and it doesn't look real good.
system("find -name find_me.txt -delete 2>//dev//null");
The problem is this doesn't actually print anything out. What I have done is:
system("find -name find_me.txt 2>//dev//null 1>result.txt");
system("find -name find_me.txt -delete 2>//dev//null");
and I just print out "fine_me.txt was deleted" for every line in result.txt. There HAS to be a better way to do this! Any ideas? Unfortunately find returns 0 if all files are scanned correctly so I can't just print out a message based on this. I would really rather not write my own search and delete function. The problem with my implementation is if it finds a file that it can't delete it's going to print out a message for it because a line is added for every file found, whether you can delete it or not. Thanks in advance. I tried googling and it doesn't look real good.
