Automation, Orchestration, and Scripting

A script named report.sh begins with #!/bin/sh and uses Bash arrays. On a Debian server, running ./report.sh fails with a syntax error, but it works on a RHEL server where /bin/sh points to Bash. What is the best fix?

Show the answer

Correct answerB. Change the first line to #!/bin/bash

On Debian, /bin/sh is typically dash, which lacks Bash arrays, so the shebang must name Bash explicitly. Renaming the file changes nothing because the kernel reads the shebang, not the extension. A shebang on line two is just a comment, and the script already executes, so permissions are not the problem.