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.

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:

#!/bin/bash/
if ["${#}" -eq 0]
  then
     echo "Missing argument(s)"
     exit 1
else
  find .  -name "*$@*"
fi

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
add comment

2 Answers

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

share|improve this answer
add comment

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