Shell Script Tutorial-Get user input using read command

September 8, 2016 | By | Reply More

Shell script is a fun and a powerful one if we can use it properly. As a newbie, I wrote this tutorial especially as a personal note but if you found it useful, you may adopt it to your own script. On this tutorial, I am going to learn about Read command. Read command is used to get the user input. We can then use the result from read command for other purposes.

Example:

Create a new shell script called script01.sh. You can use your favorite text editor such as Atom, nano or any others. I am using nano on this tutorial.

Now enter the following commands inside the editor:

Now make the script executable with this command

Now run the script

read-command-1

As you can see the echo command display the user input after the script executed.

Tags: , ,

Category: Programming, Script

Leave a Reply