Sometimes I see a command like

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

I was asked to execute this.

What does {} \; mean here?

  • This question is similar, does it help you?
    – Jon
    Aug 29, 2013 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, 2013 at 19:04
  • Yes i found the good answers here askubuntu.com/questions/85709/…
    – codeofnode
    Aug 29, 2013 at 19:19

1 Answer 1


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).

  • For the find command with the -name * argument, If you aren't sure if you need quotes around your *, then you should add double, or single quotes. So it should be -name "*". To make it easier to see what happens when you don't use quotes type this command: set +x; find . -name * -print and you'll see that what is actually passed to the find command is find . -name file1 file2 file3 file4 -print (if you had file1, file2, file3, and file4) in your current directory.
    – PatS
    Mar 10, 2021 at 21:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .