First Shell Script In linux



1. Open terminal window in Linux

2. Create a directory for all of you shell script you going to do
              mkdir shell

3. Go to the directory and create a file to  write your script
             cd shell
             vi first.sh


4. It will open vi editor to write your shell script

5. Hit 'i' and start writing following script
          #!/bin/bash
          echo "My First Shell Script"

6. Then press 'esac' key and type ':wq'. It will save the file.

7. Give the executable permission to the file using following command
      
           chmod +x first.sh

8. Run the script using following command

          ./first.sh
              (or)
          bash first.sh
              (or)
          sh first.sh

9. You will get following as output
         My First Shell Script

10. End



No comments:

Post a Comment