How to run shell script [Solved/Closed]

Report
-
Posts
40805
Registration date
Wednesday August 27, 2003
Status
Moderator
Last seen
December 5, 2019
-
Hello,

I am writing simple shell script in Ubuntu linux.

$ vi sayH
echo "Your first name please:"
read fname
echo "Hello $fname, Lets be friend!"

How to execute and Run in linux?? please usuggest me.

Regards,
Basu

1 reply

Posts
40805
Registration date
Wednesday August 27, 2003
Status
Moderator
Last seen
December 5, 2019
17
Hi,

First, append "#! /bin/bash" in top of file:

#! /bin/bash

echo "Your first name please:"
read fname
echo "Hello $fname, Lets be friend!" 

Then:

chmod u+x sayH <Enter>
./sayH <Enter>

Enjoy.