read input from user
Omkar Venkatrao Punjaji
1 min read
#! /bin/bash
echo "Enter your name: "
read name
echo "Entered name: $name"
#multi variables input
echo "Enter Names:"
read name1 name2 name3
echo "Names are : $name1 , $name2 , $name3"
#Take User input on the same line
read -p "username:" user_var
echo "username: $user_var"
read -sp "password:" passwd_var
#-sp for hiding input
echo "password: $passwd_var"
#Take multiple inputs from the user as an array
echo "Enter your Array (Names:) "
read -a names
echo "Names are: ${names[0]} , ${names[1]} ,${names[2]}"
#default user variable echo "Enter Roll No: "
read echo "Roll No: $REPLY"
1
Subscribe to my newsletter
Read articles from Omkar Venkatrao Punjaji directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Omkar Venkatrao Punjaji
Omkar Venkatrao Punjaji
Linux , Devops , c , c++ , python