0

I have a simple bash script file named: test.sh.

#!/bin/bash

ls $1;

I gave the execution permissions:

$ ./test.sh "**/*.java" 
shows only one file

where as

$ ls **/*.java
shows hundreds of files

So how to make the script work.

0

1 Answer 1

2

To enable support for ** in Bash, use the globstar option:

#!/bin/bash

shopt -s globstar

ls $1

(See §4.3.2 "The Shopt Builtin" in the Bash Reference Manual.)

Sign up to request clarification or add additional context in comments.

2 Comments

I missed that. Is it possible to use #!/bin/zsh instead of bash and avoid shopt command
@SanthoshYedidi: Yes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.