Skip to main content

Command Palette

Search for a command to run...

read input from user

Published
•1 min read•View as Markdown
O

Linux , Devops , c , c++ , python

#! /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"