A file with .sh extension is a Bash script that you can execute using the Mac Terminal. Say you have a file script.sh and you want to execute it, follow the below steps.
Step 1: Make sure the sh file has execute permissions
By default the sh file will not have execute permissions, we can check that using the ls command.
% ls -l script.sh
-rw-r--r-- 1 c2ctech staff 36 Sep 6 12:11 script.sh
If we try to run the sh script without execution permission we will get an error.
% ./script.sh
zsh: permission denied: ./script.sh
So before we can execute the script we need to add execute permissions using the command chmod +x
Example:chmod +x script.sh
Step 2: Running the .sh script file
We can run the sh file by adding a ./ before the script file name.
Example:./script.sh
If you are providing an absolute path for the file, you can do that as follows,
/Users/c2ctechtv/Desktop/script.sh
Facing issues? Have Questions? Post them here! I am happy to answer!
Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.
Follow him on: X
You can also reach out to him via e-mail: rakesh@code2care.org
- How to show line numbers in Nano on Mac
- How to install Jupyter Notebook on macOS Sonoma
- How to Disable Remote Management using Mac Terminal
- Test internet speed using macOS Terminal command
- Docker Desktop needs privileged access macOS
- Google Search Hot Trends Screensaver for Mac OS X
- How to do calculations in Mac Terminal
- How to make TextEdit the default text Editor on Mac
- How to Show Full Website Address on Safari for Mac (Ventura/Sonoma)
- The Zsh Shell - Mac Tutorial
- Opening mac Terminal
- How to change the name of your Mac running on macOS Ventura 13
- How to find the Battery Cycle Count on macOS Ventura
- How to set an emoji as Zsh terminal prompt in macOS
- How to access Trash Folder using Mac Terminal Command
- macOS Ventura XCode Command Line Tools Installation
- Hide Bluetooth icon on Mac Menu Bar macOS Ventura 13
- How to run .sh file in Mac Terminal
- Terminal Command to get the list of available shells in macOS
- How to see Storage Information on macOS Ventura
- How to Go To /usr/local/bin on Mac Terminal?
- How to do screen recording on Mac
- How to Find File and Directory Size in Mac Terminal
- Open .bash_profile File in TextEdit using Terminal
- Remove Now Playing icon from macOS Big Sur Menu Bar
- How to Split a String using delimiter in Python - Python
- How to disable SharePoint subsite creation option for owners - SharePoint
- 3 Ways to convert bytes to String in Python - Python
- How to install AWS Toolkit for Visual Studio Code - AWS
- 36: Python Program Convert Hex String to Integer - Python-Programs
- How to retrieve all SharePoint Online List Items using Rest API - SharePoint
- Show Android Studio Emulator in a Separate Window - Android-Studio
- How to install Python 3.11 on Mac - Python