Shell Script to ask user his / her name and then display it with a G’Day/Good morning message

in Categories Academic last updated April 3, 2008

This script greets user with a message. Then it displays prompt asking user her name. Once name entered it will display Gooday message using echo command.

read statement will read one line from the user (keyboard) or from file and store it to a variable called yourname.

#!/bin/bash
# Shell Script to ask user his/her name and then display it with a
# GoodDay/Good morning message
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
echo "Hi! I'm $(hostname) computer!!"
echo -n "May I know your name please ? "
read yourname
echo "Goo Day $yourname"

Share this on:

1 comment

Leave a Comment