Run the script file by double-clicking


In order to execute the script file on Mac, you need to start the terminal and specify the script file name and execute it, but it is troublesome to do this task every time with a frequently used script, so please do the following work You can enable it by double-clicking with.

When the extension of the script file is sh

On Mac, when you try to execute a script file with the extension “sh” by double-clicking, a text editor such as TextEdit or Xcode opens by default.

You can make it run by changing the application associated with the extension sh to the terminal, but you can make it run by double-clicking by changing the extension from sh to command. ..

When a script cannot be executed due to an access permission error

When the script file is executed by double-clicking, the screen below is displayed and the message “Cannot execute because you do not have appropriate access privileges.”If you see “,” you do not have sufficient permissions to execute the script file.

Open a terminal and go to the folder containing the script file.

Set the permissions on the script file by running the command below.

chmod u+x filename.command

You can check if you can assign the access right with the following command.

ls -l filename.command