Skip to main content
3 of 4
added 5 characters in body
Anthon
  • 81.4k
  • 42
  • 174
  • 228

Evaluation of find ( -exec )

I'm searching for all files that contain one of a set of strings. If they do, I change their access rights.

 find . -type f -exec grep -q '#!/bin/bash\|#!/usr/bin/grep\|#!/usr/bin/awk' {} \; -exec chmod 700 {} ;\

I'm curious how the find works when it finds a file containing that string grep -q gives me 0 so another exec executes but should not. That second exec finds all files and change the rights to all files. Why does it work and change only those files containing that string?

pnom
  • 297
  • 1
  • 3
  • 8