Monday, March 31, 2014

Writing Hello World Program in Bash


Go To Terminal ,open your text editor in my case I am using Kwrite on fedora kde.
Gedit from Gnome will also work instead of Kwrite.

as
Kwrite /home/sangram/Bash/HelloWorld.sh

Now your text editor will open add Following code in it and save.


#!/bin/bash
# My first script
echo "Hello World!"


Now close your text editor.

On Terminal change your directory to directory holding your HelloWorld.sh

One can cross verify in which directory currently he is working my issuing

pwd” command.”pwd” command stand for present working directory.

To able to run our shell script just created we need to change permissions of file hence

Kwrite /home/sangram/Bash/HelloWorld.sh

Now we are ready to run our first shell script,To run your script write following command on Terminal.

bash HelloWorld.sh

Output:


[sangram@localhost Bash]$ bash HelloWorld.sh
Hello World!
[sangram@localhost Bash]$ s

No comments:

Post a Comment