4

I am learning bash in my Mac:

There is a simplest bash script in my Mac, it named as untitled.sh:

#!/bin/bash

echo "hello"

But in my Terminal I want to run it, I get failed:

$ sudo ./untitled.sh
Password:
sudo: ./untitled.sh: command not found

I don't know why there is the error, everything is ok.

1243916142
  • 365
  • 6
  • 17

1 Answers1

8

Add execute permission for your script:

chmod +x untitled.sh

You can use

ll untitled.sh # Linux
ls -l  untitled.sh  # Mac

to check the permissions.

aircraft
  • 25,146
  • 28
  • 91
  • 166
  • An answer should not start with "try", try symbolizes that you had to guess where the problem could be. This means either OP was to unspecific about his problem, or you did not understand it well. An answer should be a solution and not a possibility – Mischa Jan 09 '18 at 08:50