Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To create a shell script using the command line, follow these steps:

  1. Open the terminal or command prompt.

  2. Navigate to the location where you want to create the script.

  3. Type touch script.sh and press Enter to create a new file named "script.sh" (replace "script" with the desired name of your script).

  4. Type chmod +x script.sh and press Enter to give the file executable permissions.

  5. Type nano script.sh and press Enter to open the file in the Nano text editor (you can use any text editor of your preference).

  6. Add your script commands to the file. For example:

#!/bin/bash
echo "Hello World!"
  1. Save the file by pressing Ctrl + X, followed by Y and Enter.

Your shell script is now ready to be executed by running ./script.sh from the terminal/command prompt.