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 🙂
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;
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