Skip to Content
Learn Linux Shell Scripting - Fundamentals of Bash 4.4
book

Learn Linux Shell Scripting - Fundamentals of Bash 4.4

by Sebastiaan Tammer
December 2018
Beginner
452 pages
12h 17m
English
Packt Publishing
Content preview from Learn Linux Shell Scripting - Fundamentals of Bash 4.4

Interactive versus non-interactive scripts

The script we have created so far uses user input, but it can't really be called interactive. As soon as the script is fired off, with or without arguments to the parameters, the script runs and completes.

But what if we do not want to use a long list of arguments, instead prompting the user for the information that is needed?

Enter the read command. The basic usage of read looks at input from the command line, and stores it in the REPLY variable. Try it out yourself:

reader@ubuntu:~$ readThis is a random sentence!reader@ubuntu:~$ echo $REPLYThis is a random sentence!reader@ubuntu:~$

After you start the read command, your terminal will go down a line and allow you to type anything you want. As soon ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Bash Scripting Fundamentals

Bash Scripting Fundamentals

Sander van Vugt

Publisher Resources

ISBN: 9781788995597Supplemental Content