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!
More Posts related to MacOS,
- Clear Screen shortcut macOS Terminal
- What is macOS Ventura?
- [fix] How to Show file extensions on all files on Mac
- How to Find Where Mac Terminal App is Located?
- AutoSave button not working on Office on Mac (Word, Excel or Powerpoint)
- macOS say command text to speech using various voices and languages
- How to change Ping TTL value on macOS
- Open .bash_profile File in TextEdit using Terminal
- How to know the Safari Version on Mac
- How to Copy full Absolute Path of a File on Mac
- 13.0 MacOS Ventura release date
- Enable spell check in Sublime Text (macOS)
- How to Display Analog Clock on Mac Menu Bar
- How to turn off Location Services macOS Ventura 13
- How to Open VS Code on Mac
- Add Bookmark macOS Safari
- How to Fix cd: too many arguments Error in Terminal: A Step-by-Step Guide
- How to install wget on macOS
- Select Line Number TextEdit on Mac
- Strikethrough Text in Excel for Mac
- How to Enable or Disable Dark Mode on macOS Ventura 13
- How to hide or display Wifi icon in macOS Bug Sur Menu Bar
- How to install Yarn on Mac (macOS)
- How to fix command not found brew (bash, zsh) on macOS Terminal
- How to Schedule Mails in macOS Ventura
More Posts:
- Read file from resources folder in Java project code - Java
- MySQL Error :1007 SQLSTATE: HY000 (ER_DB_CREATE_EXISTS) Message: Can't create database '%s'; database exists - MySQL
- Java 8 Streams map() with examples - Java
- Generate Maven Project Dependency Tree using MVN Command - Java
- [Hibernate] The method buildSessionFactory() from the type Configuration is deprecated - Java
- WhatsApp Web escanner - WhatsApp
- Error:The SDK Build Tools revision (XX.X.X) is too low for project. Minimum required is XX.X.X - Android
- cp -r Linux Command to Recursively Copy Files and Directories - Linux