Receive all updates via Facebook. Just Click the Like Button Below

First Shell Script

Open up your favorite text editor.
You can use any text editor to write the shell scripts.
Normally the shell scripts has the file extension .sh
In our example programs we will be saving the files with .sh extension.

1

firstshellscript.sh

2

The first line of every SHELL script is a commented line directed toward the interpreter.

firstshellscript.sh:
#!/bin/bash

Try the command: which bash
Use this location for your shell scripts.

Lets start with a simple script to print " Hello World "
Example:

 
#!/bin/bash
echo "Hello World"
          

Save it as " firstshellscript.sh ".
You will need to give execute permissions for your scripts.

Examples:
$ chmod +x firstshellscript.sh
or
$ chmod 755 firstshellscript.sh

Now how to run your script?
There are 3 different ways to run a shell script:
1. bash firstshellscript.sh
2. sh firstshellscript.sh
3. ./firstshellscript.sh

Try all the above.
In our examples we will be using any of these options.

3

Related posts:

Advertise here

picture picture

Follow us

picture

- Tech-Tutorials twitter.com/techcuriosity

Like us

About Techcuriosity

I am Telson, the webmaster of Techcuriosity.com and through this site, I share my knowledge and curiosities in the Tech World.


What We Offer

  • What is ..?
  • How to ..?
  • Difference between ..?
  • How .. works?
  • Get in Touch

    techcuriosity@gmail.com
    UK : +44 77 33 890 678

    picture picture

    Our Partners

  • Website Design Dubai
  • SEO Link Exchange
  • picture

    picture