Read and Display name in Shell

# program to  read a name and Display it
echo Enter Your Name
read name
echo "Your Name is " $name

Save the above Code as "readname.sh"

Now to Execute this code "sh filename.sh" in terminal

See Output of the Code

Now Lets See How this Code works

All Lines starting with a # is a comment that is it will be neglected while the code is being executed.
The Second line there is "echo Enter Your Name" . echo is used to display  the Contents on the Screen & this works similar to the printf function in C Language
The Third there is read name . this will read a string from the user here we have used the word "name". This works similar to scanf statement of C language
The fourth line  will display the Name you entered.

Comments

Popular posts from this blog

Hack Wifi with Fern Wifi Cracker

Linux Shell Script to count no of occurrences of a digit in a number

How to Decompile JAR files and View Source Code of Java Programs