Shell Scripting Read User Input

Sundar blogSundar blog
1 min read

#!/bin/bash

echo "Enter Name : "

read name

echo "Entered name : $name"

multiple input

#!/bin/bash

echo "Enter Name : "

read name1 name2 name3

echo "names : $name1,$name2,$name3"

Model:3

#!/bin/bash

read-p'username:'user_var

echo"username:$user_var"

Mode:4

#!/bin/bash

echo "Enter Name : "

read name1 name2 name3

echo "names : $name1,$name2,$name3"

Model 5

#!/usr/bin/bash

read -p 'username:' user_var

read -sp 'password:' pass_var

echo

echo "username: $user_var"

echo "password: $pass_var"

Model 5

!/usr/bin/bash

echo "Enter names:"

read -a names

echo "Names: ${names[0]},${names[1]}"

Model 6

#!/usr/bin/bash

echo "Enter name:"

read

echo "Names: $REPLY"

0
Subscribe to my newsletter

Read articles from Sundar blog directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sundar blog
Sundar blog