Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My script is supposed to: recursively look for files and directories whose names contain given strings, using find, starting in the current directory. If no arguments are given the message Missing argument(s) shall be printed before returning the error code 1 to the shell.

This is the script:

if ["${#}" -eq 0]
     echo "Missing argument(s)"
     exit 1
  find .  -name "*$@*"

I tried to use this in the terminal, but I got this error: bash: ./myfind: /bin/bash/: bad interpreter : Not a directory

Why? Is my code correct?

share|improve this question
-1 This question does not show any research effort. – Daniel Beck Jan 17 '12 at 10:40

You need to delete the slash at the end of the first line. /bin/bash is the interpreter.

share|improve this answer

You also need a space between [ and ", and between 0 and ].

Bonus: You can simplify "${#}" to just $# - There's no need to quote a variable which is always going to be a number, and there's no need to use braces unless you've got more than just a single variable within the string.

share|improve this answer
Great! thanks!Both these suggestions are valuable! – Anson Jan 18 '12 at 4:44

You must log in to answer this question.

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