Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sometimes I see a command like

find . -name * -exec ls -a {} \;

I was asked to execute this.

What does {} \; mean here?

share|improve this question
    
This question is similar, does it help you? –  Chipperyman Aug 29 '13 at 18:42
    
Please mention which operating system you are using. There are find commands for Unix, Linux, OSX, Windows and probably everything else. That looks like *nix but I can't be sure. –  terdon Aug 29 '13 at 19:04
    
Yes i found the good answers here askubuntu.com/questions/85709/… –  nodeofcode Aug 29 '13 at 19:19

1 Answer 1

up vote 3 down vote accepted

The \; is a ; fed to the program (find) by the \ escape preventing it from be handled by the shell (normally would separate commands). The -exec argument interprets everything as a command up to that inserted ; that ends the -exec stuff. Within the -exec stuff an argument of {} means "insert the file name here". So if the files were "foo" and "bar" it would execute "ls -a foo" then "ls -a bar". So all that meaning only means that because -exec is there.

The -name * part of it might have been meant with * in quotes. If it is not in quotes it will do very unpredictable things because all the file names will be inserted in place of the * you have, and those names might do bad stuff to this command. Leave -name * out for a safer run of this command (but I don't know your intentions to understand why that was in there).

share|improve this answer
    
+1 but the / in your answer should be \. –  FatalError Aug 30 '13 at 2:31

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.