To run a shell script, follow these steps:
Open a Terminal: Launch your terminal application.
Navigate to the Script's Directory: Use the
cdcommand to change to the directory where your script is located. For example:cd ~/path/to/your/scriptMake the Script Executable (if not already): If you haven't made the script executable yet, run:
chmod +x script_name.shRun the Script: You can run the script in two ways:
Using
./: This runs the script in the current shell:./script_name.shUsing
bashorsh: This runs the script using the specified shell:bash script_name.shor
sh script_name.sh
Example
If your script is named myscript.sh, you would run it like this:
cd ~/scripts
chmod +x myscript.sh # Only if not already executable
./myscript.sh
This will execute the script and display any output in the terminal.
