The trick to [tt]find[/tt] is, each argument is executed left to right, only as far as an argument evaluates as true. As soon as one of the arguments evaluates to false, it stops and goes to the next file found. In other words, by having the "[tt]-print[/tt]" after the "[tt]-exec grep ...[/tt]", it will only print the file name if the grep found something. If the text isn't in the file, the file name isn't printed. If the "[tt]-print[/tt]" was put before the "[tt]-exec grep ...[/tt]", then it would print every single file from the starting directory down, with the text from the grep following only the filenames that had it. That can be a lot of output.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.