Site icon Linux Genie

How to Take Input from User in Bash Scripting

how 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"

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

 

Exit mobile version