Predictive Hacks

The Read Statement in Linux

We will provide a simple example of the “read” statement showing how you can interact with an end-user. Note, that in this example we are not handling errors, since we want to keep it simple. Let’s create the read.sh script.

echo "Enter your First Name: "
read FIRSTNAME
echo "Enter your Last Name: "
read LASTNAME

echo ""
echo "Your Full Name is $FIRSTNAME $LASTNAME"

echo ""
echo "Enter your Age: "
read AGE

echo "Next year, you will be `expr $AGE + 1` years old."

Let’s run it now.

Note how we wrote the expression using the backticks expr $AGE + 1

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s