Reputation:
I tried to execute a file containing a shell script.
I get an error called "[[: not found" error at the last line. How to resolve it?
Upvotes: 7
Views: 5547
Reputation: 4409
You may find you stumble at other blocks later with POSIX shell related issues. People don't really understand how much bash actually provides until it's taken away. Take a look at this so you can hopefully avoid any other issues:
http://pubs.opengroup.org/onlinepubs/7908799/xcu/shellix.html
Upvotes: 0
Reputation: 14619
This interpreter:
#!/usr/bin/sh
Is either not bash
or your file doesn't have the shebang in the right place.
ls -l /usr/bin/sh
will tell you if it's a symlink to something other than bash.
If it is bash
, then check that there's no leading characters before the #!
.
Upvotes: 2
Reputation: 78561
[[
is bash
. sh
wants the [
variant.
Either change that to /usr/bin/bash
(or wherever bash is located on your system), or adjust the expression accordingly:
if [ status_of_job -eq 0 ];
Upvotes: 9
Reputation: 360872
[
is actually an executable in linux. but [[
is not.
Try
if [ status_of_job -eq 0 ]; then
(note the single []
set).
Upvotes: 5