Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

With respect to the following find command-line

find . -type f -exec grep -l strings {} \;

I do not understand the usage of -exec and {} \.

share|improve this question
add comment

1 Answer

For each find (or directory) found, execute the following command:

grep -l strings {} \;

The {} is the place holder, which stands for the file/directory found. The \; is syntactically required.

share|improve this answer
3  
the \; terminates the argument to -exec (it tells find to stop parsing the arguments as belonging to the command you want to run). You could pretty much use ";" or ';' instead - the point is, that without escaping the semicolon would be treated as command separator by the shell itself. –  peterph Nov 13 '12 at 22:51
    
@peterph: Right on. Thank you for the explanation. –  Hai Vu Nov 13 '12 at 23:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.