Published on February 28, 2017 by ProgrammingKnowledge
Want create site? Find Free WordPress Themes and plugins.

Read command – The read command allows you to prompt for input and store it in a variable. shell allows to prompt for user input.
Syntax:
read varname [more vars]
or
read –p “prompt” varname [more vars]

words entered by user are assigned to varname and “more vars”
last variable gets rest of input line.

Did you find apk for android? You can find new Free Android Games and apps.

Leave a Reply

12 Comments on "Shell Scripting Tutorial for Beginners 3 – Read User Input"

Notify of
avatar

The Ace TroubleShooter
Guest
The Ace TroubleShooter
4 months 18 days ago

Getting error for echo "username is : $user/pass_var" Says echo: command not found… Whats up with that? Ive done everything exactly the same as you've typed it =/

Pritam Chavhan
Guest
Pritam Chavhan
5 months 9 days ago

Hello Programming Knowledge,I am trying to use the read command on the Cygwin terminal but I am getting some error it says not a valid identifier 'name.Thanks.

farshad alaei
Guest
farshad alaei
7 months 4 days ago

you actually made this very difficult , its hard to understand this …

Hacker Engaged
Guest
Hacker Engaged
4 months 12 days ago

ii kinda agree

The Ace TroubleShooter
Guest
The Ace TroubleShooter
4 months 18 days ago

I disagree

Zino Holwerda
Guest
Zino Holwerda
5 months 29 days ago

what is hard about it

Kaustubh Amle
Guest
Kaustubh Amle
7 months 24 days ago

how can i give super user access to script ??like let's say the script say's #! bin/bashsudo ping -l 6 xyz.comthen the terminal promts for sudo password how can I respond to it from the shell script

Gaming Troll Pro
Guest
Gaming Troll Pro
8 months 21 days ago

can you explain me this line of code please it's in vb.netRegex.Replace("ThisIsACamelCaseString", "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1 ")

Web Developer Blog
Guest
Web Developer Blog
8 months 21 days ago

Is shell relevant in 2017?

Andy
Guest
Andy
8 months 7 days ago

Shell is very relevant. It is used to boot up almost any application that you run on a linux server. Any time a linux server is restarted, you then use shell scripts to restart any applications running on that server. Also, cron jobs running on a linux server call shell scripts for starting/restarting applications.

Sam Sharifian
Guest
Sam Sharifian
8 months 20 days ago

Shell will be relevant while a Shell based OS is relevant!! And that is likely for the next few decades!

Usman Abdullahi Abbati
Guest
Usman Abdullahi Abbati
8 months 24 days ago
please sir can you draft me the clue of this?Q1) What is the output of the following Java program:public class ArrayOutput { public static void main(String[] args) { int[] a; a = new int[10]; for(int i = 0; i < a.length; i++){ if(i % 2 == 0) a[i] = i; else a[i] = i * 2; System.out.print(a[i] + " "); } }}Q2) Modify the program of Q1 to produce the following output:0 1 4 3 16 5 36 7 64 9
wpDiscuz