Shell Scripting Tutorial – 2

Hello,

I am Aaditya Purani, and today i will teach you Input variables using `Read` in Shell Scripting. I have also made a video as usual for you guys, which is at bottom of the article 🙂

bash

So, This command takes the input and will save it into a variable.

   read var1

Code:

#!/bin/sh

echo “Hello, what is your name?”;

read varname

echo “Welcome dear”.$varname;

This code will print , the name which you inputted in the terminal.

Similarly to print many names code is

Code:

#!/bin/sh

echo “Hello, which are your best 3 movies”;

read movie1
read movie2
read movie3

echo “Cool you liked”.$movie1;
echo “Impressive you liked”.$movie2;
echo “ahha finally you liked”.$movie3;

tutorialadi

Now, you can Input Username and Password using “Read”

#!/bin/sh

read -p “Username: ” uservar

read -p “Password:” userpass

echo “Welcome”.$uservar.”Your Password is”.$userpass;

Thanks for reading. Hope you all like it 🙂 Please follow me on

https://facebook.com/aaditya.purani

https://in.linkedin.com/in/aadityapurrani

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s