I have a line in a shell script that looks like this:
java -jar "$dir/"*.jar
, since I just want to execute whatever the jar file happens to be named in that folder. But this is not working as I expected. I get the error message:
Error: Unable to access jarfile [folder-name]/*.jar
It is taking the '*' character literally, instead of doing the replacement that I want. How do I fix this?
EDIT: It is working now. I just had the wrong folder prefix :/ For anybody wondering, this is the correct way to do it.
You just need to set
failglob
:to avoid showing literal
*.jar
when none are matched in a given folder.PS: This will generate an error when it fails to match any
*.jar
as: