Question: How Do I Create a Script in Linux Terminal?
Contents

How do you write a script in Linux terminal?

How to Write Shell Script in Linux/Unix

  1. Create a file using a vi editor(or any other editor). Name script file with extension . sh.
  2. Start the script with #! /bin/sh.
  3. Write some code.
  4. Save the script file as filename.sh.
  5. For executing the script type bash filename.sh.

12 февр. 2021 г.

How do I create a .sh file in Linux terminal?

Steps to write and execute a script

  1. Open the terminal. Go to the directory where you want to create your script.
  2. Create a file with . sh extension.
  3. Write the script in the file using an editor.
  4. Make the script executable with command chmod +x <fileName>.
  5. Run the script using ./<fileName>.
Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest