How to Take Input from User in Bash Scripting


read operator is used to take input from the user and save it in a variable.

In this small but important tutorial, I am going to show you how to take input from the user in the terminal and save it in a variable by using read operator.

#!/bin/bash

echo "Enter your age"
read age

echo "Enter your gender"
read gender

echo "you are" $gender "and"  $age "years old"

how to take input from user in bash scripting

For more how-tos and tutorials, please visit Linux Genie. Have a good day.

 

Print Friendly, PDF & Email
Categories