How can I make my shell script executable

2019-07-28 09:37发布

问题:

I wrote a shell script wich opens some directories and run some script , I run this bash file by terminal (bash filename.sh), how can I make it clickable ?

回答1:

You first need to start your script with

'#!/bin/bash '

and save it as <filename>.sh Also make sure that you keep the permissions as a+x i.e all users can execute the script.



回答2:

You need to add the following shebang line to the top of your code.

#!/bin/bash

You also need to ensure that the script has executable permissions by running:

chmod a+x <filename>.sh